PageSourceSearch

https://www.boesner.com/cms/typo3temp/assets/compressed/jquery.aja…38f6a2b8ed421f9d82e6bf46.js.gzip?1784107106

js boesner.com collected 2026-10-02 10:35:39 UTC 3,610 bytes, 127 lines download raw bytes

1// page init
2jQuery(function () {
3    initLocationOverview();
4});
5
6jQuery(document).ajaxStop(function () {
7    toggleLoading(false);
8});
9
10function initLocationOverview() {
11
12    /*
13        If a user enters an address, we need to forward
14        geocode it into coordinates. The user can use
15        the HTML5 Geolocation API aswell.
16
17        We then use the coordinates to calculate the distance
18        between them and the next location.
19     */
20
21    // Disable default form submit handler
22    jQuery('#location-search-form').on("submit", function (e) {
23        e.preventDefault();
24    });
25
26    var $officeSearch = jQuery('#office-search');
27
28    if ( $officeSearch.length ) {
29        //setup before functions
30        var typingTimer;                //timer identifier
31        var doneTypingInterval = 2000;  //time in ms (5 seconds)
32
33        //on keyup, start the countdown
34        $officeSearch.keyup(function(e){
35            clearTimeout(typingTimer);
36
37            if ($officeSearch.val()) {
38                // execute search immediately if user has pressed 'enter' key
39                if (e.which === 13) {
40                    finishedInput();
41                } else {
42                    typingTimer = setTimeout(finishedInput, doneTypingInterval);
43                }
44            }
45        });
46
47        jQuery('#search-radius').change(function(){
48            finishedInput();
49        })
50    }
51}
52
53function getLocation() {
54    if (navigator.geolocation) {
55        navigator.geolocation.getCurrentPosition(finishedInput);
56    } else {
57        alert("Geolocation is not supported by this browser.");
58    }
59}
60//user is "finished typing," do something
61function finishedInput (position) {
62    toggleLoading(true);
63
64    if(position) {
65        jQuery('#office-search').val(position.coords.latitude+','+position.coords.longitude);
66        getLocations(position.coords.latitude,position.coords.longitude);
67    } else {
68        getCoordinates();
69    }
70}
71
72function getCoordinates() {
73    var openCageApi = "https://api.opencagedata.com/geocode/v1/json";
74    var ApiKey = '742db7d1d72147558d817eea7d9375f6';
75    var location = jQuery('#office-search').val();
76    var countrycode = jQuery('#office-search').attr('data-countrycode') ?? '';
77    jQuery.getJSON( openCageApi, {
78        q: location,
79        key: ApiKey,
80        countrycode: countrycode
81    })
82        .done(function( data ) {
83            if(data['results'].length > 0){
84                var lat = data['results'][0]['geometry']['lat'];
85                var lng = data['results'][0]['geometry']['lng'];
86                getLocations(lat,lng)
87            }
88        });
89}
90
91function getLocations(lat,lng) {
92    var radius = jQuery('#search-radius option:selected').val();
93    if(radius == 0){
94        radius = 9999
95    }
96
97    var $searchInput = jQuery('#office-search');
98    var type = $searchInput.data('typenum');
99    var locationAreaSearchService = $searchInput.data('url');
100
101    jQuery.ajax({
102        url: locationAreaSearchService+'?type='+type+'&lat='+lat+'&lng='+lng+'&radius='+radius,
103        context: document.body
104    }).done(function(locations) {
105        jQuery('.searchbar--results').html(locations);
106    });
107}
108
109/*
110 * Toggle loading animation and form inputs
111 */
112function toggleLoading(state) {
113    if (typeof state === "undefined") {
114        state = false;
115    }
116
117    var $form = jQuery('#location-search-form'),
118        $formLoading = $form.find(".form--loading");
119
120    if (state === true) {
121        $formLoading.addClass("loading");
122    } else {
123        $formLoading.removeClass("loading");
124    }
125
126    $form.find(":input").prop("disabled", state);
127}

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.