PageSourceSearch

https://bstore.bezeq.co.il/Content/scripts/search/bezeq_search_layout.js

js bezeq.co.il collected 2026-09-24 09:54:55 UTC 6,062 bytes, 181 lines download raw bytes

1getZoomdBool = false;
2$(document).ready(function () {
3
4    $('#autocomplete-input').blur(function () {
5        var focusReceived = false;
6
7        // Once the input loses focus, wait for the next focus event
8        $(document).one('focusin', function (event) {
9
10
11            var _div = $("#suggestions"); // item you want to check
12            var targetDiv = $(event.target); // specific div you want to check against
13
14            if (targetDiv.closest(_div).length) {
15                console.log('Item is inside the  div');
16                $("#suggestions").show().attr('aria-hidden', 'false');
17                focusReceived = true;
18            } else {
19                $("#suggestions").hide().attr('aria-hidden', 'true');
20            }
21        });
22
23        setTimeout(function () {
24            if (!focusReceived) {
25                $("#suggestions").hide().attr('aria-hidden', 'true');
26            }
27        }, 0); // This ensures it runs after focusin event if no focus occurred
28
29    });
30
31    $(document).on('blur', ".suggestion", function (e) {
32
33        var focusReceived = false;
34
35        // Once the input loses focus, wait for the next focus event
36        $(document).one('focusin', function (event) {
37
38
39            var _div = $("#suggestions"); // item you want to check
40            var targetDiv = $(event.target); // specific div you want to check against
41
42            if (targetDiv.closest(_div).length) {
43                console.log('Item is inside the  div');
44                $("#suggestions").show().attr('aria-hidden', 'false');
45                focusReceived = true;
46            } else {
47                $("#suggestions").hide().attr('aria-hidden', 'true');
48            }
49        });
50
51        setTimeout(function () {
52            if (!focusReceived) {
53                $("#suggestions").hide().attr('aria-hidden', 'true');
54            }
55        }, 0); // This ensures it runs after focusin event if no focus occurred
56
57
58    });
59
60    $('#autocomplete-input').focus(function () {
61
62        if ($('#suggestions').html().trim() === '') {
63            $('#autocomplete-input').trigger('keyup');
64        } else {
65            $("#suggestions").show().attr('aria-hidden', 'false');
66        }
67
68    });
69
70
71
72    $('#autocomplete-input').keyup(function (event) {
73
74        var _value = $('#autocomplete-input').val();
75
76        if (_value.length <= 0 || event.keyCode === 13) {
77            $("#suggestions").html("").hide().attr('aria-hidden', 'true');
78            return;
79        }
80
81        var autocompleteObj = new FormData();
82        autocompleteObj.append('query', _value);
83        autocompleteObj.append('search_type', "bstore");
84
85        var autocompleteObjJson = {
86            query: _value,
87            search_type: "bstore"
88        }
89
90
91        $.ajax({
92            // url: "http://beqez-ai-ecsloadbalancer-1837483635.il-central-1.elb.amazonaws.com/search/autocomplete",
93
94            // url: "http://tdocker.bezeq.com:8000/search/autocomplete",
95            //DapiUrl?
96            url: "https://d-api.bezeq.co.il/api/search/autocomplete",
97            type: "POST",
98            data: JSON.stringify(autocompleteObjJson),
99            contentType: "application/json; charset=utf-8",
100            dataType: "json",
101            traditional: true,
102            //data: autocompleteObj,
103            //contentType: false,
104            //processData: false,
105            success: function (data) {
106                $("#suggestions").html("");
107                let html = "";
108
109                const addSection = (title, items, className = '') => {
110                    if (items && items.length > 0) {
111                        html += `<div class="suggestion-category">${title}</div>`;
112                        items.forEach(item => {
113                            // Use textContent for security against XSS if items are purely text
114                            const text = typeof item === 'string' ? item : item.text; // Adapt if structure varies
115                            html += `<div class="suggestion ${className}" tabindex="0">${text}</div>`;
116                        });
117                    }
118
119
120                };
121
122                addSection('חיפושים פופולריים', data.popular_searches);
123                addSection('קטגוריות', data.categories, 'category-suggestion');
124                addSection('מוצרים', data.products, 'product-suggestion');
125                addSection('מותגים', data.brands, 'brand-suggestion');
126                addSection('האם התכוונת ל:', data.did_you_mean);
127
128
129                $("#suggestions").html(html);
130
131                if (html) {
132                    $("#suggestions").show().attr('aria-hidden', 'false');
133                }
134                else {
135                    $("#suggestions").hide().attr('aria-hidden', 'true');
136                }
137
138
139            },
140            error: function (data) {
141                console.error(data);
142                $("#suggestions").html("").hide().attr('aria-hidden', 'true');
143            }
144        });
145
146
147    });
148
149    $("#SubmitButtonSearch").click(function (e) {
150  
151       // var SearchPageURL = searchUrl;
152        var redirectUrl = '/search?query=' + encodeURIComponent($("#autocomplete-input").val()); // + searchLang;
153
154        
155
156        //if (document.location.href.toLowerCase().indexOf('/business') >= 0) {
157        //    redirectUrl += "&view=business";
158        //}
159        document.location.assign(redirectUrl);
160
161        //updateQueryParamWithoutRefresh('query', $("#autocomplete-input").val());
162
163        e.preventDefault();
164    });
165
166    $(document).on('click', ".suggestion", function (e) {
167        $("#autocomplete-input").val($(this).text());
168
169        $("#SubmitButtonSearch").click();
170        $("#suggestions").hide();
171
172    });
173
174    $(document).on('keyup', ".suggestion", function (e) {
175        if (e.keyCode === 13) {
176            $(this).click();
177        }
178
179    });
180
181});

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.