PageSourceSearch

https://www.cchr.de/js/routes/locator.js

js cchr.de collected 2026-09-25 07:11:06 UTC 30,342 bytes, 676 lines download raw bytes

1(function () {
2
3    JavascriptHandler.AddHandler(function () {
4
5        if (window.location.pathname != '/global-locator.html' &&
6            !window.location.pathname.startsWith('/locations/')) {
7            return;
8        }
9
10        loadjs(['https://maps.googleapis.com/maps/api/js?libraries=places,geometry,marker&key=AIzaSyCZLcRpdebfOwx2yMTYz2BYWIAbNWGNDEI'], 'locator');
11
12        // ready 
13        loadjs.ready('locator', function() {
14            loadLocator();
15        });
16    });
17
18    function loadLocator() {
19        var orgCoords = [];
20        var orgMarkers = [],
21            orgInfoWindows = [];
22        for (var org in globalOrgLocations) {
23            orgCoords.push({
24                id: org,
25                org: globalOrgLocations[org],
26                latLng: new google.maps.LatLng(globalOrgLocations[org].Latitude, globalOrgLocations[org].Longitude)
27            });
28
29        }
30
31        var distFunc = google.maps.geometry.spherical.computeDistanceBetween;
32        function sortByDistance(lat, lng) {
33            var from = new google.maps.LatLng(lat, lng);
34            orgCoords = _.sortBy(orgCoords, function (v) {
35                return distFunc(from, v.latLng);
36            });
37        }
38
39        var Locator = (function () {
40            'use strict';
41
42            function Locator() {
43                // enforces new
44                if (!(this instanceof Locator)) {
45                    return new Locator();
46                }
47            }
48
49            Locator.prototype.initAutocomplete = function () {
50                var self = this;
51                // @info https://developers.google.com/maps/documentation/javascript/places-autocomplete
52                this.lasttype = '(regions)';
53                var input = $('[name="my-location"]')[0];
54                var autocomplete = new google.maps.places.Autocomplete(input, {
55                    types: ['(regions)']
56                });
57                this.autocomplete = autocomplete;
58
59                // $(input).keyup(function () {
60                //     self.updateAutocompleteType();
61                // });
62
63                google.maps.event.addListener(autocomplete, 'place_changed', function () {
64                    self.autocompletePlaceChanged();
65                });
66                autocomplete.setFields(['address_components', 'geometry', 'types']);
67
68                $('.locator-search-button').click(function () {
69                    if ($(input).val() == "") {
70                        return;
71                    }
72                    $(input).change();
73                    $(input).focus();
74                    google.maps.event.trigger(input, 'focus', {})
75                    callWhenReady(".pac-item", function () {
76                        try {
77                            // statements
78                            var ex1 = new Event('keydown');
79                            ex1.code = "ArrowDown";
80                            ex1.key = "ArrowDown";
81                            ex1.keyCode = 40;
82                            google.maps.event.trigger(this, 'keydown', ex1);
83
84                            var ex2 = new Event('keydown');
85                            ex2.code = "Enter";
86                            ex2.key = "Enter";
87                            ex2.keyCode = 13;
88                            ex2.triggered = true;
89                            google.maps.event.trigger(input, 'keydown', ex1);
90                            google.maps.event.trigger(input, 'keydown', ex2);
91                        } catch (e) {
92                            // statements
93                            console.log(e);
94                        } finally {
95                            // statements
96                        }
97                    });
98                })
99
100
101                self.pacSelectFirst(input);
102
103                if (globalGetParams.search) {
104                    var valq = decodeURIComponent(globalGetParams.search);
105                    var $cleaner = $('<div/>').html(valq);
106                    $(input).val($cleaner.text().replace(/\+/g, ' '));
107                    $('.locator-search-button').click();
108                }
109            }
110
111            function callWhenReady(selector, callback, scope) {
112                var self = this;
113                if ($(selector).closest('body').length) {
114                    callback.call(scope);
115                } else {
116                    setTimeout(function () {
117                        callWhenReady(selector, callback, scope);
118                    }, 500);
119                }
120            }
121
122
123            Locator.prototype.autocompletePlaceChanged = function () {
124                var place = this.autocomplete.getPlace();
125                if (!place.geometry) {
126                    console.error("Failed to get geometry.");
127                    return;
128                }
129
130                if (!place.address_components) {
131                    place.address_components = [];
132                    console.error("Failed to get address_components");
133                }
134
135                var self = this;
136
137                // trackEvent("LIC Locator", "Place Changed", $('[name="my-location"]').val());
138                sortByDistance(place.geometry.location.lat(), place.geometry.location.lng());
139
140                sortByWeight(orgCoords, {
141                    lat: place.geometry.location.lat(),
142                    lng: place.geometry.location.lng(),
143                }, place, function () {
144                    self.resetMarkers();
145                    self.initMarkers(orgCoords.slice(0, 4));
146                    self.updateMap(place.geometry.location.lat(), place.geometry.location.lng(), false, place)
147                    $('.locations-search-results-title h3').html('CCHR CHAPTERS');
148                    printResults(place.formatted_address);
149                });
150
151
152            }
153
154            function sortByWeight(orgCoords, currentLocation, currentPlace, callback) {
155                var asyncWait = false;
156                // bump up orgs which a closer then 40 kms
157                try {
158                    var orgs = {
159                        Value: orgCoords,
160                    };
161
162                    var countryCode = getCountryCodeFromPlace(currentPlace) || orgCoords[0].CountryName;
163
164                    // sortWithCircle(countryCode, currentLocation, orgs, 0, 40);
165                    // sortWithCircle(countryCode, currentLocation, orgs, 41, 80);
166                    // sortWithCircle(countryCode, currentLocation, orgs, 81, 160);
167                    // sortWithCircle(countryCode, currentLocation, orgs, 161, 250);
168                    // sortWithCircle(countryCode, currentLocation, orgs, 251, 99999999999);
169
170                    // find closest ideal org
171                    var idealOrg, idealOrgIdx;
172                    for (var i = 0; i < orgCoords.length; i++) {
173                        var org = orgCoords[i].org;
174
175                        if (org.CountryCode == countryCode) {
176                            idealOrg = org;
177                            idealOrgIdx = i;
178                            break;
179                        }
180                    }
181
182
183                    // swap ideal org at the first place if it is is futher then half from closest org
184                    var a = orgCoords[0].org,
185                        b = orgCoords[1].org;
186                    var distA = getDistanceFromLatLonInKm(currentLocation.lat, currentLocation.lng, a.Latitude, a.Longitude);
187                    var distB = getDistanceFromLatLonInKm(currentLocation.lat, currentLocation.lng, b.Latitude, b.Longitude);
188
189                    if (distB - distA < distA * 0.5 && orgCoords[0].org != idealOrg && idealOrg) {
190                        var temp = orgCoords[0];
191                        orgCoords[0] = orgCoords[1];
192                        orgCoords[1] = temp;
193                    }
194
195                    if (currentPlace && currentPlace.types && currentPlace.types.length > 0 && currentPlace.types[0] == "country") {
196
197                        var country = "NONE";
198
199                        for (var i = 0; i < currentPlace.address_components.length; i++) {
200                            if (currentPlace.address_components[i].types &&
201                                currentPlace.address_components[i].types.length > 0 &&
202                                currentPlace.address_components[i].types[0] == "country") {
203                                country = currentPlace.address_components[i].short_name;
204                            }
205                        }
206
207                        for (var i = 0; i < orgCoords.length; i++) {
208                            var a = orgCoords[i].org;
209                            if (a.CountryCode == country) {
210                                var temp = orgCoords[0];
211                                orgCoords[0] = orgCoords[i];
212                                orgCoords[i] = temp;
213                                break;
214                            }
215                        }
216                    }
217                } catch (e) {
218                    console.error(e);
219                }
220
221                if (!asyncWait) {
222                    callback && callback(orgCoords);
223                }
224
225            }
226
227            function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
228                var R = 6371; // radius of the earth in km
229                var dLat = deg2rad(lat2 - lat1); // deg2rad below
230                var dLon = deg2rad(lon2 - lon1);
231                var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
232                    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
233                    Math.sin(dLon / 2) * Math.sin(dLon / 2);
234                var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
235                var d = R * c; // distance in km
236                return d;
237            }
238
239            function deg2rad(deg) {
240                return deg * (Math.PI / 180);
241            }
242
243
244
245            function getCountryCodeFromPlace(place) {
246                for (var i = 0; i < place.address_components.length; i++) {
247                    var component = place.address_components[i];
248                    for (var j = 0; j < component.types.length; j++) {
249                        var type = component.types[j];
250                        if (type == "country") {
251                            return component.short_name;
252                        }
253                    }
254                }
255            }
256
257            Locator.prototype.updateAutocompleteType = function () {
258                var val = $('[name="my-location"]').val();
259                if (isNaN(val)) {
260                    if (this.lasttype != 'geocode') {
261                        this.autocomplete.setOptions({
262                            types: ['geocode']
263                        });
264                    }
265                    this.lasttype = 'geocode';
266                } else {
267                    if (this.lasttype != '(regions)') {
268                        this.autocomplete.setOptions({
269                            types: ['(regions)']
270                        });
271                    }
272                    this.lasttype = '(regions)';
273                }
274            }
275
276            Locator.prototype.initMap = function () {
277                if (document.getElementById('map') == null) {
278                    return;
279                }
280
281                // var input_loc = $('.input-location')[0];
282                var featureOpts = [{ "featureType": "water", "stylers": [{ "saturation": 43 }, { "lightness": -11 }, { "hue": "#0088ff" }] }, { "featureType": "road", "elementType": "geometry.fill", "stylers": [{ "hue": "#ff0000" }, { "saturation": -100 }, { "lightness": 99 }] }, { "featureType": "road", "elementType": "geometry.stroke", "stylers": [{ "color": "#808080" }, { "lightness": 54 }] }, { "featureType": "landscape.man_made", "elementType": "geometry.fill", "stylers": [{ "color": "#ece2d9" }] }, { "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [{ "color": "#ccdca1" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#767676" }] }, { "featureType": "road", "elementType": "labels.text.stroke", "stylers": [{ "color": "#ffffff" }] }, { "featureType": "poi", "stylers": [{ "visibility": "off" }] }, { "featureType": "landscape.natural", "elementType": "geometry.fill", "stylers": [{ "visibility": "on" }, { "color": "#b8cb93" }] }, { "featureType": "poi.park", "stylers": [{ "visibility": "on" }] }, { "featureType": "poi.sports_complex", "stylers": [{ "visibility": "on" }] }, { "featureType": "poi.medical", "stylers": [{ "visibility": "on" }] }, { "featureType": "poi.business", "stylers": [{ "visibility": "simplified" }
282] }]
283
284                var mapOptions = {
285                    center: { lat: 0, lng: 0 },
286                    zoom: 8,
287                    // scrollwheel: false,
288                    backgroundColor: 'hsla(0, 0%, 0%, 0)',
289                    mapTypeControlOptions: {
290                        mapTypeIds: ['Map']
291                    },
292                    styles: featureOpts,
293                    mapTypeIds: 'Map',
294                    mapId: 'cchr-map'
295                };
296
297                // the geolocation call might be done by now
298                window.globalGeolocationData && globalGeolocationData.estimated_location &&
299                    (mapOptions.center = { lat: globalGeolocationData.estimated_location.latitude, lng: globalGeolocationData.estimated_location.longitude });
300
301                this.map = new google.maps.Map(document.getElementById('map'), mapOptions);
302            }
303
304            Locator.prototype.updateMap = function (lat, lng, autofill, currentPlace) {
305                $('.auto-detect').hide();
306
307                if (!autofill) {
308                    $('.locator-wrapper__unwrapped').removeClass('locator-wrapper__unwrapped');
309                    $('.locator-bg').addClass('locator-bg__hidden');
310                }
311
312
313
314                var size = 6;
315                // //sort first 6 orgs. Ideal orgs have a priority in the list
316                // for (var i = 0; i <= size; i++) {
317                //     for (var j = i + 1; j <= size; j++) {
318                //         var a = orgCoords[i].org,
319                //             b = orgCoords[j].org;
320                //         if (
321                //             (b.Status == 'ideal' && b.Type == 'clvorg' && a.Type != 'clvorg')  ||
322                //             // ((b.Status == 'ideal' && a.Status != 'ideal') && (b.Type == 'clvorg' && a.Type != 'clvorg'))  ||
323                //              ((b.Status != 'ideal' && a.Status != 'ideal') && (b.Type == 'clvorg' && a.Type != 'clvorg'))
324                //             ) {
325                //             var c = orgCoords[i];
326                //             orgCoords[i] = orgCoords[j];
327                //             orgCoords[j] = c;
328                //         }
329                //     }
330                // }
331
332
333
334
335                // build fresh bounds and extend with the requested points so fitBounds works
336                // reliably (map.getBounds() can be null/incorrect while tiles are loading)
337                var bounds = new google.maps.LatLngBounds();
338                bounds.extend(new google.maps.LatLng(lat, lng));
339                if (orgCoords && orgCoords.length > 0 && orgCoords[0].latLng) {
340                    bounds.extend(orgCoords[0].latLng);
341                }
342                // also include the second closest org when present so two locations fit
343                // if (orgCoords && orgCoords.length > 1 && orgCoords[1].latLng) {
344                //     bounds.extend(orgCoords[1].latLng);
345                // }
346
347                // fit the map to the bounds. Don't forcibly override the zoom unless
348                // the bounds collapse to a single point (only one distinct location).
349                this.map.fitBounds(bounds);
350
351                var org = orgCoords[0].org;
352                var marker = orgMarkers[org.Id];
353                var infoWindow = orgInfoWindows[org.Id];
354                var thisId = org.Id;
355
356                // If bounds represent a single point, enforce a reasonable zoom level
357                // (fitBounds will often zoom very close otherwise). Use equals() to
358                // detect collapse to a single LatLng.
359                try {
360                    var ne = bounds.getNorthEast();
361                    var sw = bounds.getSouthWest();
362                    if (ne && sw && ne.equals && ne.equals(sw)) {
363                        this.map.setZoom(13);
364                    }
365                } catch (e) {
366                    // ignore and let fitBounds decide
367                    console.error('Error checking bounds equality', e);
368                }
369
370                activateInfowindow(thisId, marker, infoWindow);
371            }
372
373
374            Locator.prototype.initMarkers = function (orgList) {
375
376
377                // initAutomplete();
378
379                // TweenMax.to($('.auto-detect'), 0.75, {autoAlpha: 1, ease: Power3.easeInOut});
380
381                // riot.compile(function() {
382
383                // here tags are compiled and riot.mount works synchronously
384                // var orginfowindows = riot.mount('orgInfoWindows', { orgs: orgList })
385                orgMarkers = [];
386                for (var i = 0; i < orgList.length; i++) {
387                    var org = orgList[i].org;
388
389
390                    orgMarkers[org.Id] = new google.maps.marker.AdvancedMarkerElement({
391                        map: this.map,
392                        position: {
393                            lat: org.Latitude,
394                            lng: org.Longitude
395                        },
396                        title: org.FullName,
397                        // ensure marker is associated with the map so InfoWindow.open receives a Map instance
398                        // icon: '/images/location-pin.svg',
399                    });
400
401
402                    orgInfoWindows[org.Id] = new google.maps.InfoWindow({
403                        headerContent: (function () {
404                            var el = document.createElement('div');
405                            el.className = 'cchr-locator-window--name';
406                            el.textContent = org.FullName || '';
407                            return el;
408                        }()),
409                        content: this.makeInfoWindow(org),
410                        maxWidth: 650,
411                    });
412
413                    new function () {
414
415                        var marker = orgMarkers[org.Id];
416                        var infoWindow = orgInfoWindows[org.Id];
417                        var thisId = org.Id;
418
419                        google.maps.event.addListener(marker, 'click', function () {
420                            activateInfowindow(thisId, marker, infoWindow);
421                        });
422
423                    }
424
425                    // orgCoords.push({
426                    //     id: org.Id,
427                    //     org: org,
428                    //     latLng: new google.maps.LatLng(org.Latitude, org.Longitude)
429                    // });
430
431                }
432
433                // });
434            }
435
436            Locator.prototype.makeInfoWindow = function (org) {
437                if (org.Image) {
438                    if (org.Image.indexOf("IMAGECACHE_PRESET") >= 0) {
439                        org.Image = "/gd/" + org.Image.replace('IMAGECACHE_PRESET', 'org-image-180-wide');
440                    } else if (org.Image.indexOf('/FURL') == -1) {
441                        org.Image = "/FURL" + org.Image;
442                    }
443                }
444
445                // if(JavascriptHandler.Path == "/dianetics-centers/") {
446                var html = '<div class="dianetics-locator--row">';
447                // if(!org.Image) {
448                //     html = '<div class="dianetics-locator--row dianetics-locator--row__bordered">';
449                // }
450                // if(org.Image) {
451                //     html = html + '<div class="dianetics-locator-org-image">' +
452                //         '<img src="'+org.Image+'"/>' +
453                //     '</div>' ;
454                // }
455
456                var lat = org.Latitude;
457                var lng = org.Longitude;
458                var directionsUrl = 'https://maps.google.com/maps?f=d&geocode=&saddr=&daddr=' + encodeURIComponent('(' + lat + ',' + lng + ')');
459                var directionsString =
460                    "<div class='locator-map-window-line'><span class='icon-direction locations-search-icon'></span> <a href='" + directionsUrl + "' target='_blank' rel='noopener'>Get Directions</a></div>";
461
462                var websiteString =
463                    "<div class='locator-map-window-line'><span class='icon-earth locations-search-icon'></span>
463 <a href='" + org.Website + "'>" +
464                    String(org.Website).replace(/http:\/\/|https:\/\//, '').replace(/\//g, '') +
465                    "</a></div>";
466
467                var emailString =
468                    "<div class='locator-map-window-line'><span class='icon-envelope locations-search-icon'></span> <a href='mailto:" + org.Email + "'>" +
469                    String(org.Email) +
470                    "</a></div>";
471
472
473
474                var items = [];
475                if (org.Address1.toUpperCase().indexOf('P.O. BOX') == -1) {
476                    items.push(directionsString);
477                }
478                items.push((org.Phone) ? "<div class='locator-map-window-line'><span class='icon-phone locations-search-icon'></span> <a href='tel:" + String(org.Phone).replace(/[^+\d]/g, '') + "'>" + org.Phone + "</a></div>" : undefined);
479                items.push((org.Email) ? emailString : undefined);
480                items.push((org.Website) ? websiteString : undefined);
481                items = items.filter(function (n) {
482                    return n !== undefined;
483                });
484
485                var text = '';
486
487
488                var locationInfo = ("<dd>" + items.join(' ') + "</dd>");
489
490
491                html = html + '<div>' +
492                    // '<div class="cchr-locator-window--name">' + org.FullName + '</div>' + 
493                    '<div class="cchr-locator-window--address"> ' + org.Address1 + '</div>' +
494                    '</div>' +
495                    locationInfo + text +
496                    '</div>';
497                return html;
498                // }
499
500                return '<div class="cchr-locator-window--name">' + org.FullName + '</div>' +
501                    '<div class="cchr-locator-window--at-name">' + strings.seminarAt + ' ' + org.FullName + '</div>' +
502                    '<div class="cchr-locator-window--address d-sm-none"><span class="icon-gps_fixed"></span> ' + org.Address1 + '</div></div>' +
503                    '<button class="btn btn-primary org-selector-item-select org-selector-item-select__small mt-0" name="orgid" value="' + org.Id + '">' + strings.select + '</button>' +
504                    '<div class="cchr-locator-window--address d-none d-md-block"><span class="icon-gps_fixed"></span> ' + org.Address1 + '</div></div>';
505            }
506
507            Locator.prototype.resetMarkers = function () {
508                for (var org in orgMarkers) {
509                    orgMarkers[org].setMap(null);
510                    if (orgMarkers[org].show) {
511                        orgMarkers[org].setMap(this.map);
512                    }
513                }
514            }
515
516            function activateInfowindow(thisId, marker, infoWindow) {
517
518                // $('.gm-style-iw').parent().css('visibility', 'hidden');
519                console.error('ACTIVATE', thisId, marker, infoWindow);
520
521                infoWindow.open(marker.map, marker);
522                // $('.gm-style-iw').parent().css('opacity', '0').removeClass('bouncey-animation-target');
523                // setTimeout(function() {
524                //     $('.gm-style-iw').parent().addClass('bouncey-animation-target');
525                //     setTimeout(function() {
526                //         $('.gm-style-iw').parent().css('opacity', '1');
527                //     }, 500);
528                // }, 15);
529
530            }
531
532
533            Locator.prototype.pacSelectFirst = function (input) {
534                // store the original event binding function
535                var _addEventListener = (input.addEventListener) ? input.addEventListener : input.attachEvent;
536
537                function addEventListenerWrapper(type, listener) {
538                    // Simulate a 'down arrow' keypress on hitting 'return' when no pac
539                    // suggestion is selected, and then trigger the original listener.
540                    if (type == "keydown") {
541                        var orig_listener = listener;
542                        window.globalLocationListener = orig_listener;
543                        listener = function (event) {
544
545                            var suggestion_selected = $(".pac-item-selected").length > 0;
546                            if ((event.which == 13 || event.which == 9) && !suggestion_selected) {
547                                event.preventDefault();
548                                event.stopPropagation();
549                                event.stopImmediatePropagation();
550                                var simulated_downarrow = $.Event("keydown", {
551                                    keyCode: 40,
552                                    which: 40
553                                });
554                                orig_listener.apply(input, [simulated_downarrow]);
555                            }
556
557                            orig_listener.apply(input, [event]);
558                        };
559                    }
560
561                    _addEventListener.apply(input, [type, listener]);
562                }
563
564                input.addEventListener = addEventListenerWrapper;
565                input.attachEvent = addEventListenerWrapper;
566            }
567
568            function isElementInView(element, fullyInView) {
569                var pageTop = $(window).scrollTop();
570                var pageBottom = pageTop + $(window).height();
571                var elementTop = $(element).offset().top;
572                var elementBottom = elementTop + $(element).height();
573
574                if (fullyInView === true) {
575                    return ((pageTop < elementTop) && (pageBottom > elementBottom));
576                } else {
577                    return ((elementTop <= pageBottom) && (elementBottom >= pageTop));
578                }
579            }
580
581
582            return Locator;
583        }())();
584
585        (function waitForjQuery() {
586            if (typeof window.$ === 'undefined') {
587                setTimeout(waitForjQuery, 50);
588                return;
589            }
590
591            // create an instance if Locator is a constructor, otherwise use as-is
592            var locatorInstance;
593            try {
594                locatorInstance = (typeof Locator === 'function') ? new Locator() : Locator;
595            } catch (e) {
596                locatorInstance = Locator;
597            }
598
599            if (locatorInstance && typeof locatorInstance.initMap === 'function') {
600                locatorInstance.initMap();
601            }
602            if (locatorInstance && typeof locatorInstance.initAutocomplete === 'function') {
603                locatorInstance.initAutocomplete();
604            }
605
606            $.ajax({
607                url: 'https://gd2.ondemandhosting.info/gcui-globaldata/geolocate-api.action',
608                dataType: 'json',
609                success: function (data) {
610                    var result = data.result;
611                    sortByDistance(result.estimated_location.latitude, result.estimated_location.longitude);
612                    printResults(null);
613                }
614            });
615
616        })();
617
618        function printResults(searchString) {
619            console.log('COORDS', orgCoords);
620
621            $('.locations-search-results').html('');
622            for (var i = 0; i < 4; i++) {
623                var text = '<div class="locations-search-result">';
624                text += '<div class="locations-icon">';
625                text += '<img src="/images/location-pin.svg" alt="Location Icon">';
626                text += '</div>';
627                text += '<div class="locations-data">';
628                text += '<dt class="location-title">' + orgCoords[i].org.FullName + '</dt>';
629
630                var lat = orgCoords[i].org.Latitude;
631                var lng = orgCoords[i].org.Longitude;
632                var directionsUrl = 'https://maps.google.com/maps?f=d&geocode=&saddr=&daddr=' + encodeURIComponent('(' + lat + ',' + lng + ')');
633                var directionsString =
634                    "<div><span class='icon-direction locations-search-icon'></span> <a href='" + directionsUrl + "' target='_blank' rel='noopener'>Get Directions</a></div>";
635
636                var websiteString =
637                    "<div><span class='icon-earth locations-search-icon'></span> <a href='" + orgCoords[i].org.Website + "'>" +
638                    String(orgCoords[i].org.Website).replace(/http:\/\/|https:\/\//, '').replace(/\//g, '') +
639                    "</a></div>";
640
641                var emailString =
642                    "<div><span class='icon-envelope locations-search-icon'></span> <a href='mailto:" + orgCoords[i].org.Email + "'>" +
643                    String(orgCoords[i].org.Email) +
644                    "</a></div>";
645
646
647
648                var items = [];
649                if (orgCoords[i].org.Address1.indexOf('P.O. Box') == -1) {
650                    items.push(directionsString);
651                }
652                items.push((orgCoords[i].org.Phone) ? "<div><span class='icon-phone locations-search-icon'></span> <a href='tel:" + String(orgCoords[i].org.Phone).replace(/[^+\d]/g, '') + "'>" + orgCoords[i].org.Phone + "</a></div>" : undefined);
653                items.push((orgCoords[i].org.Email) ? emailString : undefined);
654                items.push((orgCoords[i].org.Website) ? websiteString : undefined);
655                items = items.filter(function (n) {
656                    return n !== undefined;
657                });
658
659                if (orgCoords[i].org.Address1.length > 0) {
660                    text += '<dd class="location-address">' + orgCoords[i].org.Address1 + '</dd>';
661                }
662
663                text += ("<dd>
663" + items.join(' ') + "</dd>");
664                text += "</div>";
665                text += '</div>';
666                $('.locations-search-results').html($('.locations-search-results').html() + text);
667            }
668
669
670        }
671        
672    }
673
674    
675
676})();

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.