PageSourceSearch

https://brustersonline.com/BrustersCom/js/locationsearchV2.js?v=9

js brustersonline.com collected 2026-09-29 00:16:23 UTC 8,355 bytes, 195 lines download raw bytes

1
2$(document).on('click', '#useMyLocation', function (e) {
3    e.preventDefault();
4
5    function handleStoreSearch(latitude, longitude) {
6        $(".loading").show();
7
8        var searchurl = '/API/OnlineOrderStoreSearchCoords.aspx?lat=' + latitude + '&long=' + longitude;
9
10        jQuery.getJSON(searchurl, function (data) {
11            $("#divstores").empty();
12            $(".list-group-item", $("#divstores")).remove();
13            var outerHtml = $(".list-group-item:eq(0)", $("#divstoresclone")).prop('outerHTML');
14            if (data.length > 0) {
15                var checkOlo = 0;
16
17                function constructNewUrl(baseUrl, newParamName, newParamValue) {
18                    let url;
19                    if (!baseUrl.startsWith('http')) {
20                        url = new URL(baseUrl, window.location.origin);
21                    } else {
22                        url = new URL(baseUrl);
23                    }
24
25                    let params = new URLSearchParams(window.location.search);
26                    params.set(newParamName, newParamValue);
27                    url.search = params.toString();
28                    if (window.location.hash) {
29                        url.hash = window.location.hash;
30                    }
31                    return url.toString();
32                }
33
34                for (var i = 0; i < data.length; i++) {
35                    if (data[i].OnlineUrl) {
36                        checkOlo = 1;
37                       var htmltoadd = outerHtml;
38
39                        var baseUrl = data[i].isNewOLO
40                            ? 'BrustersCom/Cart.aspx'
41                            : 'BrustersCom/ShoppingCart.aspx';
42
43                        var newUrl = constructNewUrl(baseUrl, 'number', data[i].Number);
44
45                        htmltoadd = htmltoadd
46                            .replaceAll('[LAT]', data[i].lat)
47                            .replaceAll('[LNG]', data[i].lng)
48                            .replaceAll('[ONLINEURL]', newUrl)
49                            .replaceAll('[STORE PHONE]', data[i].phone)
50                            .replaceAll('[STORE NAME]', data[i].Name)
51                            .replaceAll('[STORE ADDRESS]', data[i].MAPADDRESS)
52                            .replaceAll('[MILES AWAY]', data[i].Distance)
53                            .replaceAll('[MAPADDRESS]', data[i].googleMapImage)
54                            .replaceAll('[MAPADDRESS2]', data[i].googleMapImage);
55
56                        $("#divstores").append(htmltoadd);
57                    }
58                }
59
60                if (checkOlo === 0) {
61                    $("#divstores").append('<p>We are sorry. No participating stores in your area.</p>');
62                }
63            } else {
64                $("#divstores").append('<p>We are sorry. No participating stores in your area.</p>');
65            }
66        }).done(function () {
67            $("#landingPage").hide();
68            $("#storelist").show();
69            $(".loading").hide();
70        });
71    }
72
73    function fallbackToIPInfo() {
74        $(".loading").show();
75
76        $.get("https://ipinfo.io?token=b738936dc8442b", function (response) {
77            if (response.loc) {
78                var loc = response.loc.split(',');
79                handleStoreSearch(loc[0], loc[1]);
80            } else {
81                $(".loading").hide();
82                sweetAlert("Notice", "Unable to retrieve your location. Please try again.", "info");
83            }
84        }, "jsonp").fail(function () {
85            $(".loading").hide();
86            sweetAlert("Notice", "Geolocation and IP lookup both failed.", "info");
87        });
88    }
89
90    if (navigator.geolocation) {
91        navigator.geolocation.getCurrentPosition(
92            function (position) {
93                handleStoreSearch(position.coords.latitude, position.coords.longitude);
94            },
95            function (error) {
96                fallbackToIPInfo();
97            },
98            {
99                timeout: 7000
100            }
101        );
102    } else {
103        fallbackToIPInfo();
104    }
105});
106
107
108//$(document).on('click', '#useMyLocation', function (e) {
109//    e.preventDefault();
110//    $(".loading").show();
111
112//    $.get("https://ipinfo.io?token=b738936dc8442b", function (response) {
113//        console.log(response);
114//        var loc = response.loc.split(',');
115//        var latitude = loc[0];
116//        var longitude = loc[1];
117
118//        // Construct the URL for the API call
119//        var searchurl = '/API/OnlineOrderStoreSearchCoords.aspx?lat=' + latitude + '&long=' + longitude;
120
121//        jQuery.getJSON(searchurl, function (data) {
122//            $("#divstores").empty();
123//            $(".list-group-item", $("#divstores")).remove();
124//            var outerHtml = $(".list-group-item:eq(0)", $("#divstoresclone")).prop('outerHTML');
125//            if (data.length > 0) {
126//                var checkOlo = 0;
127//                var currentPageUrl = window.location.href.split('?')[0]; // Get the current page URL without query string
128
129//                // Function to construct the new URL with preserved query parameters and hash
130//                function constructNewUrl(baseUrl, newParamName, newParamValue) {
131//                    let url;
132
133//                    // Check if the baseUrl is relative or absolute
134//                    if (!baseUrl.startsWith('http')) {
135//                        // Resolve relative baseUrl to an absolute URL
136//                        url = new URL(baseUrl, window.location.origin);
137//                    } else {
138//                        // Use the baseUrl directly if it's already absolute
139//                        url = new URL(baseUrl);
140//                    }
141
142//                    let params = new URLSearchParams(window.location.search);
143
144//                    // Add the new parameter
145//                    params.set(newParamName, newParamValue);
146
147//                    // Construct the final URL
148//                    url.search = params.toString();
149//                    if (window.location.hash) {
150//                        url.hash = window.location.hash;
151//                    }
152
153//                    return url.toString();
154//                }
155
156
157//                for (var i = 0; i < data.length; i++) {
158//                    if (data[i].OnlineUrl) {
159//                        checkOlo = 1;
160//                        var htmltoadd = outerHtml;
161
162//                        // Determine the base URL based on the value of isNewOLO
163//                        var baseUrl = data[i].isNewOLO ? 'BrustersCom/Cart.aspx' : 'BrustersCom/ShoppingCart.aspx';
164//                        var newUrl = constructNewUrl(baseUrl, 'number', data[i].Number); // Construct the new URL with query string
165
166//                        htmltoadd = htmltoadd.replace('[LAT]', data[i].lat)
167//                            .replace('[LNG]', data[i].lng)
168//                            .replace('[ONLINEURL]', newUrl)
169//                            .replace('[STORE PHONE]', data[i].phone)
170//                            .replace('[STORE NAME]', data[i].Name)
171//                            .replace('[STORE ADDRESS]', data[i].MAPADDRESS)
172//                            .replace('[MILES AWAY]', data[i].Distance)
173//                            .replace('[MAPADDRESS]', data[i].googleMapImage)
174//                            .replace('[MAPADDRESS2]', data[i].googleMapImage);
175//                        // Replace for both order buttons
176//                        htmltoadd = htmltoadd.replace('[ONLINEURL]', newUrl)
177//                                             .replace('[ONLINEURL]', newUrl);
178//                        $("#divstores").append(htmltoadd);
179//                    }
180//                }
181
182//                if (checkOlo == 0) {
183//                    $("#divstores").append('<p>We are sorry. No participating stores in your area.</p>');
184//                }
185//            } else {
186//                $("#divstores").append('<p>We are sorry. No participating stores in your area.</p>');
187//            }
188
189//        }).done(function () {
190//            $("#landingPage").hide();
191//            $("#storelist").show();
192//            $(".loading").hide();
193//        });
194//    }, "jsonp");
195//});

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.