PageSourceSearch

https://www.ametek.de/-/media/themes/oneweb/oneweb/oneweb/oneweb/scripts/43-component-handlebar.js?thm=1

js ametek.de collected 2026-10-06 16:21:00 UTC 6,270 bytes, 170 lines download raw bytes

1var owHandlebar = (function () {
2    function sendHandleBarRequest(item) {
3        var hbObject = {
4            Endpoint: $(item).attr('ow-endpoint'),
5            SourceId: $(item).attr('ow-source-id'),
6            ConfigId: $(item).attr('ow-config-id'),
7            Keyword: owCommon.getKeyword(),
8            Filters: owCommon.getFilters(),
9            Parameters: {},
10            Append: false
11        };
12
13        if($('.ow-search-box').length > 0){
14            hbObject.Language = $('.ow-search-box').attr('ow-language');
15        }
16
17        if (hbObject.Endpoint != undefined && hbObject.Endpoint.length > 0 && hbObject.SourceId != undefined) {
18            $(item).each(function () {
19                $.each(this.attributes, function () {
20                    if (this.specified) {
21                        if (this.name.indexOf('ow-') != -1) {
22                            hbObject.Parameters[this.name] = this.value;
23                        }
24                    }
25                });
26            });
27            fetch(hbObject);
28            $(item).addClass('ow-initialized');
29        }
30
31        return hbObject;
32    };
33
34    const initiate = function () {
35        const filterHandleBar = $('.ow-search-template[is-filter]').not('.ow-initialized');
36        if (filterHandleBar) {
37            [].map.call(filterHandleBar, function (item) {
38                sendHandleBarRequest(item);
39            });
40        }
41
42        const searchHandleBar = $('.ow-search-template[is-result]').not('.ow-initialized');
43        if (searchHandleBar) {
44            [].map.call(searchHandleBar, function (item) {
45                sendHandleBarRequest(item);
46            });
47        }
48    };
49
50    var fetch = function (hbObject) {
51        if(hbObject.PageType == 0){
52            owCommon.removeUrlParam('page');
53        }else{
54            var currentPage = owCommon.getQueryStringParams('page');
55            if(currentPage != undefined && currentPage.length > 0){
56                hbObject.PagesToSkip = currentPage - 1;
57            }
58        }
59
60        $.ajax({
61            contentType: 'application/json; charset=utf-8',
62            url: hbObject.Endpoint,
63            data: JSON.stringify({ 'parameters': hbObject }),
64            cache: false,
65            async: true,
66            dataType: 'json',
67            type: "POST",
68            success: function (response) {
69                if (response != undefined) {
70                    if (owCommon.isValidJson(response)) {
71                        populate(hbObject, response);
72                    }
73                }
74            },
75            error: function (xhr) {
76                console.log(xhr);
77            }
78        });
79    }
80
81    var populate = function (hbObject, handleBarData) {
82        if (hbObject.SourceId != undefined) {
83            var identifier = hbObject.SourceId;
84            var parentDiv = $('[ow-source-id=' + identifier + ']');
85            if (parentDiv == undefined) {
86                console.log('parent div not found for ' + identifier);
87                return;
88            }
89            if (handleBarData != undefined) {
90                parentDiv.removeClass('d-none');
91                var templateDiv = parentDiv.find('.ow-template');
92                var containerDiv = parentDiv.find('.ow-container');
93
94                if (templateDiv == undefined || containerDiv == undefined) {
95                    console.log('template/container not found for ' + identifier);
96                    return;
97                }
98
99                var content = '';
100                var hbTemplate = '';
101                try {
102                    hbTemplate = Handlebars.compile(templateDiv.html());
103                    content = hbTemplate(handleBarData);
104                }
105                catch (e) {
106                    console.log('error parsing handlebar for ' + identifier);
107                    console.log(e);
108                    return;
109                }
110
111                if (hbObject.Append == true) {
112                    containerDiv.append(content);
113                } else {
114                    if($(containerDiv).hasClass('slider-widget')){
115                        owSliderCard.destory();
116                        containerDiv.html(content);
117                        owSliderCard.init();
118                    }else{
119                        containerDiv.html(content);
120                    }
121                }
122
123                if (parentDiv.attr('is-result') != undefined) {
124                    var searchObject = {
125                        Wrapper: parentDiv,
126                        Data: handleBarData,
127                        Append: hbObject.Append,
128                        Keyword: hbObject.Keyword,
129                        Filters: hbObject.Filters
130                    }
131                    owSearch.renderResults(searchObject);
132                }
133
134                if (parentDiv.attr('is-filter') != undefined && parentDiv.attr('is-alphabet-filter') == undefined) {
135                    updateFilterVisibility(parentDiv, handleBarData);
136                }
137            } else {
138                parentDiv.addClass('d-none');
139            }
140        }
141    };
142
143    var updateFilterVisibility = function (parentDiv, data) {
144        if (data.Values == undefined || data.Values.length == 0) {
145            parentDiv.addClass('d-none');
146        } else {
147            parentDiv.removeClass('d-none');
148        }
149        var filterWrappers = parentDiv.find('.filter-facet-wrapper .filter-item');
150        if (filterWrappers.length == 0) {
151            parentDiv.find('.filter-facet-wrapper').addClass('d-none');
152        } else {
153            parentDiv.find('.filter-facet-wrapper').removeClass('d-none');
154            var filterWrapperContainer = parentDiv.parents('.filter-wrapper-container');
155            if(filterWrapperContainer != undefined){
156                filterWrapperContainer.removeClass('d-none');
157                filterWrapperContainer.find('.filter-tab').removeClass('d-none')
158            }
159        };
160    }
161    return {
162        init: initiate,
163        populate: populate,
164        fetch: fetch,
165    };
166})();
167
168$().ready(function () {
169    owHandlebar.init();
170});

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.