PageSourceSearch

https://www.cookfood.net/scripts/cook.js?202609221200

js cookfood.net collected 2026-09-25 19:53:53 UTC 3,574 bytes, 126 lines download raw bytes

1$(function () { COOK.Setup(); });
2var COOK = {
3    Setup: function () {
4        if ($('#search').length > 0) {
5            Search.Initialize();
6        }
7
8      
9
10    }
11}
12
13var Search = {
14    SID: 0,
15    LID: 0,
16    Timer: null,
17    Initialize: function () {
18        
19        var s = $('#search');
20        if (s != null) {
21           s.on('keyup', function(x) {
22
23               if (Search.Timer != null)
24                   clearTimeout(Search.Timer);
25               
26               Search.Timer = setTimeout(Search.DoSearch, 200);
27
28
29            });
30        }
31    },
32    DoSearch: function() {
33        Search.SID++;
34        var more = $('#searchresults .more');
35        if (more != null) {
36            more.text('Searching....');
37            
38        }
39        $.postJSON({
40            url: $('#searchform').data('suggest-action'),
41            data: { search: escape($('#search').val()), sid: Search.SID },
42            success: Search.SearchDone}
43    );
44
45        if (typeof dataLayer !== 'undefined') {
46            dataLayer.push({
47                'event': 'VirtualPageView',
48                'virtualPageURL': '/search/'
49            });
50
51            dataLayer.push({
52                'event': 'GAEvent',
53                'eventCategory': 'Search',
54                'eventAction': 'Product Search',
55                'eventLabel': escape($('#search').val())
56            });
57        }
58        
59    },
60    SearchDone: function (x) {
61        
62        if (x.SID >= Search.LID) {
63            Search.LID = x.SID;
64            var sr = $('#searchresults');
65            sr.empty();
66            
67            var el = $('<ul />');
68            
69            el.appendTo(sr);
70
71            $.each(x.Results, function (e,y) {
72                
73                var li = $('<li />');
74                li.appendTo(el);
75                var a = $('<a />');
76                a.appendTo(li);
77                a.attr('href', y.URL);
78                var j = $('<img width="60" height="60" />');
79                j.attr('src', y.ImageURL);
80                j.appendTo(a);
81                var s = $('<span />');
82                s.appendTo(a);
83                s.text(unescape(y.Title));
84                
85            });
86
87            if (x.NumResults > 5) {
88                var a = $('<a />');
89                a.appendTo(sr);
90
91                a.attr('href', "/search/?search=" + $('#search').val());
92                a.text("More Results >");
93                a.addClass('more').addClass('topborder');
94            }
95            if (x.NumResults == 0) {
96                var a = $('<a />');
97                a.appendTo(sr);
98
99                a.attr('href', "/search/?search=" + $('#search').val());
100                a.text("No results found");
101                a.addClass('more');
102            }
103        }
104    }
105};
106function getPageType() {
107    var uri = window.location.href.toLowerCase();
108    switch (uri) {
109        case String(uri.match(/^.*\/menu.*/i)):
110            return "category_page";
111        case String(uri.match(/^.*\/product.*/i)):
112            return "product_page";
113        case String(uri.match(/^.*\/your-account.*/i)):
114        case String(uri.match(/^.*\/AccountInfo.*/i)):
115            return "account_page";
116        case String(uri.match(/^.*\/checkout.*/i)):
117            return "checkoutflow_page";
118        default:
119            return "information_page";
120    }
121}
122
123function removeTrailingSlash(inputUrl) {
124    var outputUrl = inputUrl.replace(/\/+$/, '');
125    return outputUrl;
126}

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.