PageSourceSearch

https://hansimglueck-burgergrill.de/typo3conf/ext/hig_site/Resources/Public/js/locationpage.js?1774947384

js hansimglueck-burgergrill.de collected 2026-09-26 02:08:38 UTC 85,273 bytes, 2,317 lines download raw bytes

1var higpage = {};
2var map,mapDetails, markers, infowindows, marker, infowindow/*, loc_obj = window.loc_obj*/,
3    myLatLng, loc_length, loc_ext_length, mapObject, hasLocation = false,searchLocation, infowindow, contentStrings,
4    contentStringsExt, search_location_icon, SearchMarker, LocTextListScrolls = [], LocTextListScrollCalled;
5
6var distances = [];
7
8var bewerben_text = $(".location-jobs ul li a").first().text();
9
10var LocListTimeOut = 0;
11var LocListDelay = 100;
12var weekdaytitles = [];
13var useDate = "";
14var initZoom = 6;
15window.addEventListener('load', (event) => { initMap(); });
16
17
18higpage.defaultPosition = {};
19higpage.defaultPosition.lat = 48.136010;
20higpage.defaultPosition.lng = 11.583841;
21
22if (page_language){
23    if (page_language == 8 || page_language == 9){
24        higpage.defaultPosition.lat = 52.222279;
25        higpage.defaultPosition.lng = 5.758729;
26        initZoom = 7;
27    }
28}
29
30$(function(){
31    init_locations();
32
33    var LocationListSwipeOptions = {
34        triggerOnTouchEnd : true,
35        swipeStatus : LocListSwipeStatus,
36        allowPageScroll : "vertical",
37        threshold : 5,
38        triggerOnTouchLeave: false
39    };
40    $(".location-text-list-navigation").swipe(LocationListSwipeOptions);
41
42    for (let j = 0; j < 7; j++) {
43        weekdaytitles[j] = $("#opening_table tr:nth-child(" + (j + 1) + ") td:first-child").text();
44    }
45
46    $("a[href='#changedate']").on("click",function(){
47        useDate = window.prompt("Alternatives Datum eingeben","2021-02-18");
48    });
49
50
51    /* Standort Related on Ready */
52
53    "use strict";
54
55
56
57    //console.log(loc_obj);
58
59    /*
60    //Versuch den Backevent abzufangen - verursacht Chaos - so lang nicht explizit gewünscht kommt das nicht.
61    window.onpopstate = function(event) {
62        console.log("location: " + document.location + ", state: ", event.state);
63
64        if(!event.state || event.state.status == "close"){
65            CloseLocation(false);
66        }
67
68    };*/
69
70
71    var location_search_key_timer;
72    
73    /* Maps related on Load */
74    if ($("#google-map-holder").length > 0) {
75      
76    //initMap();
77        //google.maps.event.addDomListener(window, 'load', initMap);
78		
79		/*
80        if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Safari") > 0) {
81            setTimeout(function(){
82                initMap();
83                $("#google-map-holder").css("opacity",1);
84            }, 100);
85        } else {
86		    google.maps.event.addDomListener(window, 'load', initMap);    
87        }
88        */
89
90        $(".input-search a").on("click",function(e){
91            e.preventDefault();
92
93            searchByTextfield();
94        });
95
96        $("#location-search").focus(function(e){
97            if($("#location-search").val() == $("#location-search").attr("data-address")){
98                $("#location-search").val("");
99            }
100        });
101        $("#location-search").blur(function(e){
102           if($("#location-search").val() == "" && $("#location-search").attr("data-address") != ""){
103               $("#location-search").val($("#location-search").attr("data-address"));
104           }
105        });
106
107
108
109
110    }
111
112    if (window.loc_obj) {
113        var loc_length = window.loc_obj.length;
114    }
115
116
117    $(".locationsearchfieldlist ul li").mousedown(function() {
118        var index = $(this).index();
119        $(".locationsearchfield").val($(this).attr("data-name"));
120        $("ul.locationsearchfieldlist li").hide();
121        window.location.href = $(this).find("a").attr("href")
122    });
123    $(".locationsearchfield").on("focus", function() {
124        $(".locationsearchfield").val("");
125        $("ul.locationsearchfieldlist li").hide()
126    });
127
128    $(".button-fav").on("click",function(){
129        $(this).toggleClass("active");
130        $(this).attr("id");
131
132        if($(this).hasClass("active")){
133            	$.cookie('favorite-yextid',$(this).attr("data-YextId"), { expires: 365 });
134        } else {
135            $.removeCookie('favorite-yextid', { path: '/' });
136        }
137
138    });
139
140
141    $(".overlay-holder").insertAfter($("article"));
142
143    $(".overlay-holder").on("click",function(){ /* closeLocation*/
144        if($(".overlay-holder .location-details").length){
145            CloseLocation();
146        }
147    }).children().on("click",function(e){
148        e.stopPropagation();
149    });
150
151    $(".location-details .btn-close, .location-details .back-link").on("click",function(){
152        CloseLocation();
153    });
154    
155
156});
157
158
159
160function init_locations(){
161
162    if(typeof loc_obj !== 'undefined'){
163	    
164        var locationTextListItem = "";
165        //$(".location-text-list ul li").remove();
166        /* Alle Standorte in Textliste unten auf der Seite */
167        /*
168        for (var i = 0; i < loc_obj.length; i++) { 
169            loc_obj[i].originalID = i;
170
171
172            loc_obj[i].name_zusatz = loc_obj[i].address.line1;
173            if (typeof loc_obj[i].c_website_hig_name !== "undefined"){
174                //console.log(i, loc_obj[i].c_website_hig_name)
175                loc_obj[i].name_zusatz = loc_obj[i].c_website_hig_name
176            }
177
178            var classCountry = "";
179            if(typeof loc_obj[i].address.countryCode !== "undefined"){
180
181                classCountry = " country-" + loc_obj[i].address.countryCode.toLowerCase();
182
183            }
184
185            var link = getLocationLink(i);
186
187            locationTextListItem =  "<li class='" +classCountry+ "' data-id='"+ i +"'>" +
188                "<div class='list-item-left'><a href='" + link + "'><span>" + loc_obj[i].address.city + "</span>&nbsp;"
189                + loc_obj[i].name_zusatz
190                + "</a></div><div class='list-item-right'></div>"
191                + "</li>"
192            //$(".location-text-list ul").append(locationTextListItem);
193        }
194        */
195
196        $(".location-text-list ul li").sort(asc_sort).appendTo('.location-text-list ul');
197        function asc_sort(a, b){
198            return ($(b).text()) < ($(a).text()) ? 1 : -1;
199        }
200
201        $(".location-text-list ul li").sort(asc_sort).appendTo('.location-text-list ul');
202
203        $(".location-text-list ul li").each(function(){
204            var ThisChar = $(this).text();
205            ThisChar = ThisChar.substr(0,1);
206            var setThis = false;
207
208
209            if(typeof LocTextListScrolls[ThisChar.toLowerCase()] === 'undefined'){
210                LocTextListScrolls[ThisChar.toLowerCase()] = $(this).position().top;
211                setThis = true;
212            }
213            // console.log("ThisChar " + ThisChar + " top: " + $(this).position().top + " setThis: " + setThis);
214
215        });
216
217        // console.log("LocTextListScrolls", LocTextListScrolls);
218
219
220        //$(".location-text-list ul").css("opacity", 1);
221    }
222}
223
224mapObject = {
225        scrollwheel: true,
226        styles: [
227            {
228                "elementType": "geometry",
229                "stylers": [
230                    {
231                        "color": "#f5f5f5"
232                    }
233                ]
234            },
235            {
236                "elementType": "labels.icon",
237                "stylers": [
238                    {
239                        "visibility": "off"
240                    }
241                ]
242            },
243            {
244                "elementType": "labels.text.fill",
245                "stylers": [
246                    {
247                        "color": "#616161"
248                    }
249                ]
250            },
251            {
252                "elementType": "labels.text.stroke",
253                "stylers": [
254                    {
255                        "color": "#f5f5f5"
256                    }
257                ]
258            },
259            {
260                "featureType": "administrative.land_parcel",
261                "elementType": "labels",
262                "stylers": [
263                    {
264                        "visibility": "off"
265                    }
266                ]
267            },
268            {
269                "featureType": "administrative.land_parcel",
270                "elementType": "labels.text.fill",
271                "stylers": [
272                    {
273                        "color": "#bdbdbd"
274                    }
275                ]
276            },
277            {
278                "featureType": "poi",
279                "elementType": "geometry",
280                "stylers": [
281                    {
282                        "color": "#eeeeee"
283                    }
284                ]
285            },
286            {
287                "featureType": "poi",
288                "elementType": "labels.text",
289                "stylers": [
290                    {
291                        "visibility": "off"
292                    }
293                ]
294            },
295            {
296                "featureType": "poi",
297                "elementType": "labels.text.fill",
298                "stylers": [
299                    {
300                        "color": "#757575"
301                    }
302                ]
303            },
304            {
305                "featureType": "poi.business",
306                "stylers": [
307                    {
308                        "visibility": "off"
309                    }
310                ]
311            },
312            {
313                "featureType": "poi.park",
314                "elementType": "geometry",
315                "stylers": [
316                    {
317                        "color": "#e5e5e5"
318                    }
319                ]
320            },
321            {
322                "featureType": "poi.park",
323                "elementType": "labels.text.fill",
324                "stylers": [
325                    {
326                        "color": "#9e9e9e"
327                    }
328                ]
329            },
330            {
331                "featureType": "road",
332                "elementType": "geometry",
333                "stylers": [
334                    {
335                        "color": "#ffffff"
336                    }
337                ]
338            },
339            {
340                "featureType": "road",
341                "elementType": "labels.icon",
342                "stylers": [
343                    {
344                        "visibility": "off"
345                    }
346                ]
347            },
348            {
349                "featureType": "road.arterial",
350                "elementType": "labels.text.fill",
351                "stylers": [
352                    {
353                        "color": "#757575"
354                    }
355                ]
356            },
357            {
358                "featureType": "road.highway",
359                "elementType": "geometry",
360                "stylers": [
361                    {
362                        "color": "#dadada"
363                    }
364                ]
365            },
366            {
367                "featureType": "road.highway",
368                "elementType": "labels.text.fill",
369                "stylers": [
370                    {
371                        "color": "#616161"
372                    }
373                ]
374            },
375            {
376                "featureType": "road.local",
377                "elementType": "labels",
378                "stylers": [
379                    {
380                        "visibility": "off"
381                    }
382                ]
383            },
384            {
385                "featureType": "road.local",
386                "elementType": "labels.text.fill",
387                "stylers": [
388                    {
389                        "color": "#9e9e9e"
390                    }
391                ]
392            },
393            {
394                "featureType": "transit",
395                "stylers": [
396                    {
397                        "visibility": "off"
398                    }
399                ]
400            },
401            {
402                "featureType": "transit.line",
403                "elementType": "geometry",
404                "stylers": [
405                    {
406                        "color": "#e5e5e5"
407                    }
408                ]
409            },
410            {
411                "featureType": "transit.station",
412                "elementType": "geometry",
413                "stylers": [
414                    {
415                        "color": "#eeeeee"
416                    }
417                ]
418            },
419            {
420                "featureType": "water",
421                "elementType": "geometry",
422                "stylers": [
423                    {
424                        "color": "#c9c9c9"
425                    }
426                ]
427            },
428            {
429                "featureType": "water",
430                "elementType": "labels.text.fill",
431                "stylers": [
432                    {
433                        "color": "#9e9e9e"
434                    }
435                ]
436            }
437        ],
438        panControl: false,
439        zoomControl: true,
440        mapTypeControl: false,
441        scaleControl: true,
442        streetViewControl: false,
443        fullscreenControl: false
444        /*mapId: 'hig_location_map'*/
445        /*,animatedZoom: true*/
446    };
447    
448var Clusterimage = "data:image/svg+xml;base64," + window.btoa("<?xml version='1.0' encoding='UTF-8' standalone='no'?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
448<svg width='100%' height='100%' viewBox='0 0 40 40' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;'><circle cx='20' cy='20' r='20' style='fill:#dcd500;'/></svg>");
449    
450
451
452    var fontFamily = "'Avenir Next LT W05 Thin Cond'";
453    var clusterStyles = [{
454        fontFamily: fontFamily,
455        fontWeight: "400",
456        textColor: "white",
457        textSize: 23,
458        url: Clusterimage,
459        height: 40,
460        width: 40,
461        iconAnchor: [20, 20]
462    }, {
463        fontFamily: fontFamily,
464        fontWeight: "400",
465        textColor: "white",
466        textSize: 24,
467        url: Clusterimage,
468        height: 40,
469        width: 40,
470        iconAnchor: [20, 20]
471    }, {
472        fontFamily: fontFamily,
473        fontWeight: "400",
474        textColor: "white",
475        textSize: 25,
476        url: Clusterimage,
477        height: 40,
478        width: 40,
479        iconAnchor: [20, 20]
480    }];
481    
482
483/* ==========================================================================
484    Sammlung der Maps Funktionen
485   ========================================================================== */
486
487function initMap() { /* Map Init Start */
488	if (!document.getElementById("google-map-holder"))
489		return;
490
491     setTimeout(function(){
492        $("#google-map-holder").css("opacity",1);
493    }, 1000);
494
495    $('#google-map-holder').on('click', function () { 
496        UC_UI.showSecondLayer();
497    });
498
499    if (typeof google !== 'object') 
500		return;
501	
502    loc_length = loc_obj.length;
503    markers = [];
504    infowindows = [];
505
506    
507
508    map = new google.maps.Map(document.getElementById("google-map-holder"), mapObject);
509
510    mapObject.disableDefaultUI = true;
511    mapObject.draggable = false;
512
513	
514    //mapDetails = new google.maps.Map(document.getElementById("details-google-map-holder"), mapObject);
515    //console.log('map', mapDetails); // 
516
517    /*window.higfunc.map = map;*/
518    myLatLng = {
519        lat: higpage.defaultPosition.lat,
520        lng: higpage.defaultPosition.lng
521    };
522    map.setZoom(initZoom);
523    map.setCenter(myLatLng);
524    var location_icon = {
525        url: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg id='Ellipse_123' data-name='Ellipse 123' fill='%23fff' stroke='%23dcd500' stroke-width='1'%3E%3Ccircle cx='12' cy='12' r='12' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='11.5' fill='none'/%3E%3C/g%3E%3C/svg%3E%0A",
526        size: new google.maps.Size(24, 24),
527        origin: new google.maps.Point(0, 0),
528        anchor: new google.maps.Point(12, 12)
529    };
530    var location_new_icon = {
531        url: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg id='Ellipse_124' data-name='Ellipse 124' fill='%23dcd500' stroke='%23dcd500' stroke-width='1'%3E%3Ccircle cx='12' cy='12' r='12' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='11.5' fill='none'/%3E%3C/g%3E%3C/svg%3E%0A",
532        size: new google.maps.Size(24, 24),
533        origin: new google.maps.Point(0, 0),
534        anchor: new google.maps.Point(12, 12)
535    };
536    search_location_icon = {
537
538        url: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cg id='Gruppe_1490' data-name='Gruppe 1490' transform='translate(3886 7516)'%3E%3Cg id='Ellipse_86' data-name='Ellipse 86' transform='translate(-3884 -7514)' fill='none' stroke='%23663e7f' stroke-width='1'%3E%3Ccircle cx='8' cy='8' r='8' stroke='none'/%3E%3Ccircle cx='8' cy='8' r='7.5' fill='none'/%3E%3C/g%3E%3Cg id='Gruppe_1488' data-name='Gruppe 1488' transform='translate(0.5 0.5)'%3E%3Cline id='Linie_81' data-name='Linie 81' x2='20' transform='translate(-3886.5 -7506.5)' fill='none' stroke='%23663e7f' stroke-width='1'/%3E%3Cline id='Linie_82' data-name='Linie 82' y2='20' transform='translate(-3876.5 -7516.5)' fill='none' stroke='%23663e7f' stroke-width='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A",
539        size: new google.maps.Size(40, 50),
540        origin: new google.maps.Point(0, 0),
541        anchor: new google.maps.Point(10, 10)
542    };
543
544
545
546    //console.log("Map init is running");
547    infowindow = new google.maps.InfoWindow;
548    contentStrings = [];
549    contentStringsExt = [];
550    var onclickeventStr = "";
551    var onclickevent = "";
552
553
554
555    find_closest_marker(higpage.defaultPosition.lat,higpage.defaultPosition.lng);
556    updateLocationList();
557
558    
559
560    /*Geolocation erst abfagen wenn die Karte geladen ist, gab sonst fehler */
561    google.maps.event.addListenerOnce(map, 'idle', function(){
562        getGeolocation();
563
564        // remove click event from #google-map-holder
565        $('#google-map-holder').off('click');
566        
567    });
568
569    $("#google-map-holder").css("opacity",1);
570
571    var Standort_slug = page_arguments[0];
572    
573    if (page_arguments.length > 1){
574	    var Standort_hash = page_arguments[1];
575    }
576    
577    /*
578    if (Standort_slug.indexOf('#') > 0){
579      var slug_arr = Standort_slug.split('#');
580      Standort_slug = slug_arr[0];
581      var Standort_hash = slug_arr[1];
582    }
583    */
584    
585    /* Alle Marker Erstellen */
586    for (var i = 0; i < loc_length; i++) {
587        var icontoSet = location_icon;
588
589        if (loc_obj[i].c_aufWebsiteAusblenden) continue;
590
591        if (false/*loc_obj[i].loc_new*/){
592            icontoSet = location_new_icon;
593        }
594
595        // console.log("lat: ", loc_obj[i].yextDisplayCoordinate.latitude, "lng: ",loc_obj[i].yextDisplayCoordinate.longitude);
596
597
598        marker = new google.maps.Marker({
599            position: {
600                lat: loc_obj[i].yextDisplayCoordinate.latitude,
601                lng: loc_obj[i].yextDisplayCoordinate.longitude
602            },
603            title: loc_obj[i].city,
604            icon: icontoSet
605//                 animation: google.maps.Animation.DROP
606        });
607
608		var yextid = loc_obj[i].meta.id;
609		
610        google.maps.event.addListener(marker, "click", function(marker, yextid) {
611            return function () {
612                OpenLocation(marker,yextid);
613            }
614        }(marker, yextid));
615
616        markers.push(marker);
617        loc_obj[i].marker = marker;
618
619
620        /* Falls die URL diesen Standort beinhaltet, dann diesen Standort öffnen */
621        var this_slug = getLastSlug(loc_obj[i].c_baseURL);
622        if(typeof this_slug !== undefined && this_slug != null){
623            //console.log(loc_obj[i].c_baseURL, this_slug);
624            
625            if(Standort_slug == this_slug){
626                //OpenLocation(marker,i, Standort_hash); //azz: hat zu /standort/undefined und dann 404 geführt
627            }
628        }
629        this_slug = "";
630    }
631
632
633    /* ### Autocomplete für Suchfeld hinzufügen ### */
634
635    const input = document.getElementById("location-search");
636    const autocomplete = new google.maps.places.Autocomplete(input,{ types: ["geocode"] });
637
638    autocomplete.bindTo("bounds", map);
639    autocomplete.setFields(["geometry"]);
640    autocomplete.setComponentRestrictions({
641        country: ["de", "at", "ch", "nl"],
642    });
643
644    enableEnterKey(input)
645
646    autocomplete.addListener("place_changed", () => {
647        const place = autocomplete.getPlace();
648        //console.log("Place_changed: ", place);
649
650
651
652        if (!place.geometry) {
653            // User entered the name of a Place that was not suggested and
654            // pressed the Enter key, or the Place Details request failed.
655            console.log("Es konnte keine Adresse gefunden werden.")
656            return;
657        }
658
659        hasLocation = true;
660
661
662        // If the place has a geometry, then present it on a map.
663        /*if (place.geometry.viewport) {
664            map.fitBounds(place.geometry.viewport);
665        } else {
666            map.setCenter(place.geometry.location);
667            map.setZoom(17); // Why 17? Because it looks good.
668        }*/
669
670
671
672        myLatLng = {
673            lat: place.geometry.location.lat(),
674            lng: place.geometry.location.lng()
675        };
676        findLocation(myLatLng);
677
678
679        /*
680        let address = "";
681        if (place.address_components) {
682            address = [
683                (place.address_components[0] &&
684                    place.address_components[0].short_name) ||
685                "",
686                (place.address_components[1] &&
687                    place.address_components[1].short_name) ||
688                "",
689                (place.address_components[2] &&
690                    place.address_components[2].short_name) ||
691                "",
692            ].join(" ");
693        }*/
694
695        //console.log("Location: " + place.geometry.location);
696
697
698
699    });
700
701
702
703    // Sets a listener on a radio button to change the filter type on Places
704    // Autocomplete.
705    function setupClickListener(id, types) {
706        const radioButton = document.getElementById(id);
707        radioButton.addEventListener("click", () => {
708            autocomplete.setTypes(types);
709        });
710    }
711
712
713    /* Clusters ist die Zussmmenfassung von verschiedenen Punkten zu einem Punkt mit Zahl */
714
715        
716
717    var markerCluster = new MarkerClusterer(map, markers, {
718        minimumClusterSize: 5,
719        /*imagePath: stylesheet_directory_uri + "/images/base/googlemaps/m",*/
720        styles: clusterStyles
721    });
722
723    var DetailsMarkers = Array.from(markers);
724	
725	/*
726    var DetailsMarkerCluster = new MarkerClusterer(mapDetails, DetailsMarkers, {
727        minimumClusterSize: 5,
728        styles: clusterStyles
729    });
730	*/
731
732	
733    /*google.maps.event.addDomListener(window, "resize", function() {
734        var center = map.getCenter();
735        google.maps.event.trigger(map, "resize");
736        map.setCenter(center)
737    });*/
738    window.addEventListener('resize',function() {
739        var center = map.getCenter();
740        google.maps.event.trigger(map, "resize");
741        map.setCenter(center)
742    });
743
744    // ??
745    // these funcs arent there..?!
746    if (window.higSetMarker && window.higSetFocusOnMap) window.higSetFocusOnMap(window.higSetMarker)
747}
748
749function enableEnterKey(input) {
750    /* Store original event listener */
751    const _addEventListener = input.addEventListener
752
753    const addEventListenerWrapper = (type, listener) => {
754        if (type === 'keydown') {
755            /* Store existing listener function */
756            const _listener = listener
757            listener = (event) => {
758                /* Simulate a 'down arrow' keypress if no address has been selected */
759                const suggestionSelected = document.getElementsByClassName('pac-item-selected').length
760                if (event.key === 'Enter' && !suggestionSelected) {
761                    const e = new KeyboardEvent('keydown', {
762                        key: 'ArrowDown',
763                        code: 'ArrowDown',
764                        keyCode: 40,
765                    })
766                    _listener.apply(input, [e])
767                }
768                _listener.apply(input, [event])
769            }
770        }
771        _addEventListener.apply(input, [type, listener])
772    }
773
774    input.addEventListener = addEventListenerWrapper
775}
776
777function getGeolocation() {
778    /*$("#nav_location-search", "#location-search").val("");*/
779
780    navigator.geolocation.getCurrentPosition(function(position) {
781        hasLocation = true;
782
783        myLatLng = {
784            lat: position.coords.latitude,
785            lng: position.coords.longitude
786        };
787
788        const geocoder = new google.maps.Geocoder();
789        const latlng = {
790            lat: parseFloat(position.coords.latitude),
791            lng: parseFloat(position.coords.longitude),
792        };
793
794        geocoder.geocode({ location: latlng }, (results, status) => {
795            if (status === "OK") {
796                if (results[0]) {
797
798                    $("#location-search").val(results[0].formatted_address);
799                    $("#location-search").attr("data-address", results[0].formatted_address);
800                    //console.log("Adresse bekommen", results)
801
802                    findLocation(myLatLng)
803                } else {
804                    //console.log("Keine Adresse bekommen", results)
805                }
806            } else {
807                //console.log("Geocoder failed due to: " + status);
808            }
809        });
810
811    }, function() {
812
813        hasLocation = false;
814        //console.log("Did not get Geolocation", "hasLocation", hasLocation);
815        myLatLng = {
816            lat: higpage.defaultPosition.lat,
817            lng: higpage.defaultPosition.lng
818        };
819        map.setZoom(initZoom);
820        map.setCenter(myLatLng);
821        //console.log("Geolocation NICHT bekommen", myLatLng);
822
823        SearchMarker = new google.maps.Marker({
824            position: myLatLng,
825            map: map,
826            icon: search_location_icon
827        });
828    });
829}
830
831function getBoundsZoomLevel(bounds, mapDim) {
832    var WORLD_DIM = {
833        height: 256,
834        width: 256
835    };
836    var ZOOM_MAX = 21;
837
838    function latRad(lat) {
839        var sin = Math.sin(lat * Math.PI / 180);
840        var radX2 = Math.log((1 + sin) / (1 - sin)) / 2;
841        return Math.max(Math.min(radX2, Math.PI), -Math.PI) / 2
842    }
843
844    function zoom(mapPx, worldPx, fraction) {
845        return Math.floor(Math.log(mapPx / worldPx / fraction) / Math.LN2)
846    }
847    var ne = bounds.getNorthEast();
848    var sw = bounds.getSouthWest();
849    var latFraction = (latRad(ne.lat()) - latRad(sw.lat())) / Math.PI;
850    var lngDiff = ne.lng() - sw.lng();
851    var lngFraction = (lngDiff < 0 ? lngDiff + 360 : lngDiff) / 360;
852    var latZoom = zoom(mapDim.height, WORLD_DIM.height, latFraction);
853    var lngZoom = zoom(mapDim.width, WORLD_DIM.width, lngFraction);
854    return Math.min(latZoom, lngZoom, ZOOM_MAX)
855}
856
857function find_closest_marker(Lat, Lng) {
858    var lat = Lat;
859    var lng = Lng;
860    var R = 6371;
861
862    var closest = -1;
863    var i = 0;
864    for (i = 0; i < loc_obj.length; i++) {
865        var mlat = loc_obj[i].yextDisplayCoordinate.latitude; /*markers[i].position.lat();*/
866        var mlng = loc_obj[i].yextDisplayCoordinate.longitude; /*markers[i].position.lng();*/
867        /*console.log(mlat, mlng);*/
868
869
870        var dLat = rad(mlat - lat);
871        var dLong = rad(mlng - lng);
872        var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong / 2) * Math.sin(dLong / 2);
873        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
874        var d = R * c;
875        distances[i] = d;
876        loc_obj[i].loc_distance = d;
877
878        if (closest == -1 || d < distances[closest]) {
879            closest = i
880        }
881    }
882    return closest
883}
884
885function searchByTextfield() {
886    var address = $("#location-search").val();
887
888    //console.log("Suche über Textfeld " + address);
889    var geocoder = new google.maps.Geocoder;
890    geocoder.geocode({
891        address: address
892    }, function(results, status) {
893        //console.log("Ergebnis", results, status);
894        if (status == google.maps.GeocoderStatus.OK) {
895            var Lat = results[0].geometry.location.lat();
896            var Lng = results[0].geometry.location.lng();
897            myLatLng = {
898                lat: Lat,
899                lng: Lng
900            };
901            hasLocation = true;
902            findLocation(myLatLng)
903
904        } else {}
905    })
906}
907
908function clickMarker(id){
909    google.maps.event.trigger(markers[id], "click");
910}
911
912function findLocation(myLatLng) { /* Karte auf diese Koordinaten ausrichten */
913    // infowindow.close();
914    //console.log("findLocation", myLatLng);
915
916    //console.log("location-search: ", $("#location-search").val());
917
918    if($("#location-search").val() != ""){
919        $("#location-search").attr("data-address",$("#location-search").val());
920    }
921
922
923    /*$("ul.highlight_list li").hide();*/
924
925    var Lat = myLatLng.lat;
926    var Lng = myLatLng.lng;
927
928
929    if (SearchMarker !== undefined) {
930        SearchMarker.setPosition(new google.maps.LatLng(Lat, Lng))
931    } else {
932        SearchMarker = new google.maps.Marker({
933            position: {
934                lat: Lat,
935                lng: Lng
936            },
937            icon: search_location_icon,
938            map: map,
939            animation: google.maps.Animation.DROP
940
941        })
942    }
943
944    map.setCenter(SearchMarker.position);
945    map.setZoom(11);
946
947    var closest_maker = find_closest_marker(Lat, Lng);
948
949
950    /* Karte so zoomen, dass nächster Marker mit im Bild ist*/
951    if (markers[closest_maker] != undefined){
952        if (map.getBounds().contains(markers[closest_maker].getPosition()) == false) {
953
954            // console.log("Nähster Punkt ist nicht innerhalb der Karte");
955            if (markers[closest_maker].position.lat() > Lat) {
956                var lat_max = markers[closest_maker].position.lat();
957                var lat_min = Lat
958            } else {
959                var lat_min = markers[closest_maker].position.lat();
960                var lat_max = Lat
961            }
962            if (markers[closest_maker].position.lng() > Lng) {
963                var lng_max = markers[closest_maker].position.lng();
964                var lng_min = Lng
965            } else {
966                var lng_min = markers[closest_maker].position.lng();
967                var lng_max = Lng
968            }
969
970            map.setCenter(new google.maps.LatLng((lat_max + lat_min) / 2, (lng_max + lng_min) / 2));
971            map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng(lat_min, lng_min), new google.maps.LatLng(lat_max, lng_max)));
972            var zoomLevel = map.getZoom();
973            map.setZoom(zoomLevel - 1);
974
975            infowindow.setContent(contentStrings[closest_maker])
976        }
977    }
978
979    updateLocationList();
980}
981
982function updateLocationList(){
983
984    $(".location-list ul li").remove();
985    var loc_obj2Sort = Array.from(loc_obj);
986
987    if(hasLocation) {
988        loc_obj2Sort.sort(compareValues("loc_distance"));
989    }
990    else {
991        loc_obj2Sort.sort(compareValues("address.city"));
992    }
993
994    for (var i = 0; i < loc_obj2Sort.length; i++) {
995
996        if (loc_obj2Sort[i].c_aufWebsiteAusblenden) continue;
997
998        var ThisDistance = "";
999        if(hasLocation){
1000            ThisDistance = DistanceToText(loc_obj2Sort[i].loc_distance);
1001        }
1002
1003        var ThisNew = "";
1004
1005        //Falls Status Neu oder im Bau oder über Businesshours Temporarily Closed angegeben wurde.
1006        if(loc_obj2Sort[i].c_website_status == 'NEU' || loc_obj2Sort[i].c_website_status == 'IM_BAU' || (typeof loc_obj2Sort[i].hours !== "undefined" && typeof loc_obj2Sort[i].hours.reopenD
1006ate !== "undefined")) {
1007
1008            var status = loc_obj2Sort[i].c_website_status;
1009            if(typeof loc_obj2Sort[i].hours !== "undefined" && typeof loc_obj2Sort[i].hours.reopenDate !== "undefined"){
1010                status = "VORÜBERGEHEND_GESCHLOSSEN";
1011            }
1012
1013            var imBauString = $('.location-list').attr('data-text-ListImBau');
1014            if (status == 'IM_BAU' && imBauString) status = imBauString;
1015            
1016            ThisNew = "<span class='new status-" + status.toLowerCase() +"'>" + status.replace('_', ' ') + "</span>";
1017        }
1018        
1019        var locationLink = loc_obj2Sort[i].c_baseURL;
1020	    
1021	    // FAKE EN LINK INTO URL -> no access to actual page url here...
1022	    if (languageSlug) locationLink = locationLink.replace('.de/', '.de'+languageSlug+'/');
1023		
1024		if ($(".location-list").hasClass("delivery-list")){
1025			var orderLink = '';
1026			var pickupLink = '';
1027			var orderString = $('.delivery-list').attr('data-text-listorder');
1028			var pickupString = $('.delivery-list').attr('data-text-listpickup');
1029			
1030			var orderTarget = loc_obj2Sort[i].c_website_lieferserivce;
1031			if (orderTarget && orderString) 
1032				orderLink = "<a href='" + orderTarget + "' class='order-link' target='_blank'><span class='name' title='" + orderString + " in " + loc_obj2Sort[i].address.city + "'>" + orderString + "</span></a>";
1033			
1034			if (loc_obj2Sort[i].c_abholen && pickupString) 
1035				pickupLink = "<a href='" + loc_obj2Sort[i].c_abholen + "' class='order-link' target='_blank'><span class='name' title='" + pickupString + " in " + loc_obj2Sort[i].address.city + "'>" + pickupString + "</span></a>";
1036			
1037	        $(".location-list ul").append("<li title='" + loc_obj2Sort[i].address.city + " " + loc_obj2Sort[i].address.postalCode + "' " +
1038	            "data-id='" + loc_obj2Sort[i].originalID + "'"+
1039	            "data-distance='" + loc_obj2Sort[i].loc_distance + "'>" +
1040	            "<a href='" + locationLink + "' class='loc-link'>"+ThisNew + "<span class='name'>" + loc_obj2Sort[i].address.city + " " + loc_obj2Sort[i].c_website_hig_name + "</span>" +
1041	            "<span class='street'>" + loc_obj2Sort[i].address.line1 + "</span></a><div class='order-link-wrap'>" +
1042	            orderLink + pickupLink + 
1043	            "</div></li>");			
1044		} else if ($(".location-list").hasClass("burgerspecial-list")){
1045            var specialString = '';
1046            if ( loc_obj2Sort[i].c_zusatzinfoSpecials ){
1047                specialString = $('.burgerspecial-list').attr('data-text-specialstext');
1048                specialString = "<br><span class='special-text'><b>" + specialString + '</b> ' + loc_obj2Sort[i].c_zusatzinfoSpecials + "</span>";
1049            
1050            $(".location-list ul").append("<li title='" + loc_obj2Sort[i].address.city + " " + loc_obj2Sort[i].address.postalCode + "' " +
1051	            "data-id='" + loc_obj2Sort[i].originalID + "'"+
1052	            "data-distance='" + loc_obj2Sort[i].loc_distance + "'>" +
1053	            "<a href='" + locationLink + "' class='loc-link'>"+ThisNew + "<span class='name'>" + loc_obj2Sort[i].address.city + "</span>" +
1054	            "<span class='street'>" + loc_obj2Sort[i].address.line1 + "</span>" + specialString +  
1055	            "</a></li>");
1056            } 
1057		} else {
1058	        $(".location-list ul").append("<li title='" + loc_obj2Sort[i].address.city + " " + loc_obj2Sort[i].address.postalCode + "' " +
1059	            "data-id='" + loc_obj2Sort[i].originalID + "'"+
1060	            "data-distance='" + loc_obj2Sort[i].loc_distance + "'>" +
1061	            "<a href='" + locationLink + "' class='loc-link'>"+ThisNew + "<span class='name'>" + loc_obj2Sort[i].address.city + " " + loc_obj2Sort[i].c_website_hig_name + "</span>" +
1062	            "<span class='street'>" + loc_obj2Sort[i].address.line1 + "</span>" +
1063	            "<span class='distance'>" + ThisDistance + "</span>" +	
1064	            "</a></li>");
1065	    }
1066    }
1067
1068    if(!hasLocation) {
1069        $(".location-list ul li").hide();
1070        $(".location-list-none").hide();
1071    } else {
1072        $(".location-list ul li").hide();
1073        $(".location-list-none").hide();
1074
1075        var LocationsToShow = $(".location-list ul li").filter(function() {
1076            return  $(this).attr("data-distance") < 100;
1077        });
1078
1079        LocationsToShow.show();
1080
1081        if(LocationsToShow.length == 0) $(".location-list-none").show();
1082    }
1083
1084    updateLocationListHeight();
1085
1086	/*
1087    $(".location-list ul li, .location-text-list-wrapper  ul  li").unbind("click").on("click", function(e) {
1088        clickMarker($(this).attr("data-id"));
1089    });
1090    */
1091
1092    /*$(".location-text-list-wrapper ul li a").on("click",function (e) {
1093        e.preventDefault();
1094    });*/
1095}
1096
1097function updateLocationListHeight(){
1098    var oneHeight = $(".location-list ul li").outerHeight();
1099    var Len = $(".location-list ul li:visible").length;
1100    var visibleHeight = Len * oneHeight;
1101
1102    if(Len < 7) newHeight = Len * oneHeight;
1103    else newHeight = 7 * oneHeight;
1104
1105    /*console.log("oneHeight", oneHeight,"visibleHeight", visibleHeight);*/
1106
1107    $(".location-list-more").hide();
1108
1109    $(".location-list ul").css("height", newHeight + "px");
1110}
1111
1112
1113/* ========================================
1114    Location-Text-List
1115=========================================== */
1116
1117$(".location-text-list-wrapper").on("scroll",function(e){
1118    if(LocTextListScrollCalled == true){
1119        LocTextListScrollCalled = false;
1120    } else {
1121        $(".location-text-list-navigation span.selected").removeClass("selected");
1122
1123    }
1124});
1125
1126function LocListSwipeStatus(event, phase, direction, distance){
1127    var element = $(".location-text-list-navigation");
1128    // console.log("Event", event, "Phase", phase, "Direction", direction, "Distance", distance);
1129    // console.log(event);
1130
1131    if (typeof event.touches !== 'undefined' && event.touches.length > 0){
1132        //console.log("ClientX " + parseInt(event.touches[0].clientX) + " PageX " +  parseInt(event.touches[0].pageX));
1133
1134        var Charnum = parseInt((event.touches[0].clientX - element.offset().left) / (element.outerWidth() * 0.951539)  * 25);
1135        if (Charnum > -1 && Charnum < 26){
1136            /*console.log(Charnum);*/
1137            $(".location-text-list-navigation span").removeClass("selected").eq(Charnum).addClass("selected");
1138
1139
1140            var SearchedChar = $(".location-text-list-navigation span.selected").text();
1141            SearchedChar = SearchedChar.toLowerCase();
1142            $(".location-text-list-wrapper").scrollTop(LocTextListScrolls[SearchedChar]);
1143            LocTextListScrollCalled = true;
1144
1145
1146        }
1147    }
1148}
1149
1150
1151/* ==========================================================================
1152    Location Detailpage
1153   ========================================================================== */
1154
1155function OpenLocation(marker,i, urlhash = '') {
1156    //console.log('OpenLocation ' + i);
1157    //console.log(marker);
1158
1159    try{
1160	    
1161	    //var link = getLocationLink(i);
1162        //var link = loc_obj[i].c_baseURL;
1163        var linkObj = loc_obj.find(l => (l.meta.id == i));
1164        var link = linkObj.c_baseURL;
1165		if ((page_language == 4 || page_language == 5) && linkObj.c_websiteURL_CH) link = linkObj.c_websiteURL_CH;
1166		if ((page_language == 6 || page_language == 7) && linkObj.c_websiteURL_AT) link = linkObj.c_websiteURL_AT;
1167		if ((page_language == 8 || page_language == 9) && linkObj.c_websiteURL_NL) link = linkObj.c_websiteURL_NL;
1168
1169		window.location.href = link;
1170		return;
1171       
1172        //console.log("Overlay öffnen", marker,i, loc_obj);
1173		
1174		
1175		/*
1176        var website_status = '';
1177        if (loc_obj[i].c_website_status)
1178            website_status = loc_obj[i].c_website_status.toLowerCase();
1179
1180        //console.log('website_status', website_status);
1181        $('.open_today').show();
1182
1183
1184        if(typeof loc_obj[i] == "undefined"){
1185            return false;
1186        }
1187
1188
1189        
1190        //window.history.pushState({status: "popup"}, "",link );
1191
1192        //scrollTop(0, 200);
1193
1194        //Fotos ersetzten
1195        if(typeof loc_obj[i].c_website_standortfotos !== "undefined" && loc_obj[i].c_website_standortfotos.length > 0){
1196            $(".location-details .image-slider").show();
1197
1198            $(".location-details .image-slider .slider *").remove();
1199            loc_obj[i].c_website_standortfotos.forEach(function(item,index){
1200
1201                if(typeof item.url !== "undefined" && item.url !== ""){
1202                    var slide = "<div class=\"slide\" style=\"background-image: url(/typo3conf/ext/hig_site/Yext/" + item.url + ")\" data-img='" + item.url + "'></div>";
1203                    $(".location-details .image-slider .slider").append(slide);
1204                }
1205            });
1206
1207            $(".location-details .image-slider .slider").data("initialised", false);
1208            initSlider();
1209
1210
1211        } else {
1212            $(".location-details .image-slider").hide();
1213        }
1214
1215        //console.log("picture URL", loc_obj[i].c_website_standortfotos[0].thumbnails[0].url);
1216        if(typeof loc_obj[i].c_website_standortfotos !== "undefined"){
1217            if(typeof loc_obj[i].c_website_standortfotos[0].url !== "undefined" && loc_obj[i].c_website_standortfotos[0].url != ""){
1218                //console.log("Foto URL ", loc_obj[i].c_website_standortfotos[0].url)
1219                $(".location-image").show();
1220                $(".location-image").css("background-image","url(/typo3conf/ext/hig_site/Yext/" + loc_obj[i].c_website_standortfotos[0].url + ")");
1221            }
1222            else {
1223                $(".location-image").hide();
1224            }
1225        } else {
1226            $(".location-image").hide();
1227        }
1228
1229
1230
1231	        var bookatablecode = "";
1232            var bookaLanguage = (page_language == 1) ? 'en-UK' : 'de-DE';
1233            var reservisioncode = "";
1234            
1235            if (typeof loc_obj[i].c_website_Reservision !== "undefined" && loc_obj[i].c_website_Reservision != ""){
1236	        	$('#bookatable-coming-soon').hide();
1237				$('#bookatable').hide();
1238				$('#reservision_holder').empty().show();
1239	            	        
1240	            if ($('.reservision-widget').length == 0){
1241		            
1242					reservisioncode = loc_obj[i].c_website_Reservision;
1243					var rsv = $(reservisioncode).attr('src'); // + '?nostartbutton';
1244					if (rsv){
1245						///setTimeout(function(){
1246							var s = document.createElement('script');
1247							s.setAttribute('src', rsv);
1248							s.setAttribute('async', 'async');
1249							//s.setAttribute('defer', 'defer');
1250							s.setAttribute('data-uniqid', 'rsvn_'+i);
1251							//console.log(s);
1252							$('#reservision_holder')[0].appendChild(s);
1253							$('#reservision_holder').show();
1254						//},300);
1255					} else {
1256						$('#reservision_holder').hide();
1257						$('#bookatable-coming-soon').show();
1258					}
1259				}
1260	            
1261            } else {            
1262	            if(typeof loc_obj[i].c_website_bookatable !== "undefined" && loc_obj[i].c_website_bookatable != ""){		            
1263       				$('#reservision_holder').hide();
1264		            
1265	                bookatablecode = "<html><body><script type=\"text/javascript\" src=\"https://bda.bookatable.com/deploy/lbui.direct.min.js\"></script>" +
1266	                    "<script type=\"text/javascript\">" +
1267	                    "LBDirect_Embed({\n" +
1268	                    "connectionid  :  \"" + loc_obj[i].c_website_bookatable + "\",\n" +
1269	                    "style  :  {\n" +
1270	                    "baseColor  :  \"beb800\",\n" +
1271	                    "useFlatDesign : true\n" +
1272	                    "},\n" +
1273	                    "language  :  \"" + bookaLanguage + "\"\n" +
1274	                    "});</script></body></html>";
1275	                $('#bookatable-coming-soon').hide();
1276	                $('#bookatable').show();
1277	            } else {
1278	                $('#bookatable-coming-soon').show();
1279	                $('#bookatable').hide();
1280	            }
1281	
1282	            setTimeout(function(){
1283	                var iframe =  document.getElementById('bookatable');
1284	                iframe.contentWindow.document.open();
1285	                iframe.contentWindow.document.open();
1286	                iframe.contentWindow.document.write(bookatablecode);
1287	                iframe.contentWindow.document.close();
1288	
1289	                //console.log("Bookatable:", iframe, bookatablecode);
1290	            },300);
1291	        }
1292
1293		// Reservieren Tab
1294		// rsvn -> open tab
1295		if (typeof loc_obj[i].c_website_Reservision !== "undefined" && loc_obj[i].c_website_Reservision != ""){
1296			$("a[href='#tab-reservieren']").addClass('reservision_widget_invoke').attr('data-id', 'rsvn_'+i);
1297			
1298		// booka -> go to reservationUrl
1299        } else if(typeof loc_obj[i].reservationUrl !== "undefined" && typeof  loc_obj[i].reservationUrl.url !== "undefined" && loc_obj[i].reservationUrl.url != ""){
1300            $("a[href='#tab-reservieren']").removeClass('reservision_widget_invoke').attr("data-url",loc_obj[i].reservationUrl.url).get(0).addEventListener("click", function (e){
1301			if ($(this).hasClass('reservision_widget_invoke')) return;
1302            e.preventDefault();
1303            e.stopPropagation();
1304            if($(".r-mobile:visible").length > 0){
1305                var win = window.open($(this).attr("data-url"), '_blank');
1306                win.focus();
1307            }
1308        }, true)
1309        }
1310
1311
1312        $("span#name").text(loc_obj[i].address.city + " " + loc_obj[i].name_zusatz);
1313
1314        if(typeof loc_obj[i].address !== "undefined"){
1315            $(".address_title_city").text(loc_obj[i].address.city);
1316            $(".address_title_street").text(loc_obj[i].name_zusatz)
1317            $(".address_address").text(loc_obj[i].address.line1);
1318            $(".address_zip").text(loc_obj[i].address.postalCode);
1319            $(".address_city").text(loc_obj[i].address.city);
1320        }
1321
1322        // Google Attributes mit anzeigen
1323        if(typeof loc_obj[i].googleAttributes !== "undefined"){
1324            $(".attributes").show();
1325            $("#attr-dine-in,#attr-delivery,#attr-takeout").removeClass("yes no");
1326            if(typeof loc_obj[i].googleAttributes.serves_dine_in !== "undefined" && loc_obj[i].googleAttributes.serves_dine_in == "true"){
1327                $("#attr-dine-in").addClass("yes");
1328            } else {
1329                $("#attr-dine-in").addClass("no");
1330            }
1331            if(typeof loc_obj[i].googleAttributes.has_delivery !== "undefined" && loc_obj[i].googleAttributes.has_delivery == "true"){
1332                $("#attr-delivery").addClass("yes");
1333            } else {
1334                $("#attr-delivery").addClass("no");
1335            }
1336            if(typeof loc_obj[i].googleAttributes.has_takeout !== "undefined" && loc_obj[i].googleAttributes.has_takeout == "true"){
1337                $("#attr-takeout").addClass("yes");
1338            } else {
1339                $("#attr-takeout").addClass("no");
1340            }
1341        }
1342        else {
1343            $(".attributes").hide();
1344
1345        }
1346
1347
1348
1349        if(typeof loc_obj[i].c_website_SpeiseoptionenInfo !== "undefined" && loc_obj[i].googleAttributes.c_website_SpeiseoptionenInfo != ""){
1350            $(".optionenInfo").show().html(loc_obj[i].c_website_SpeiseoptionenInfo);
1351        }
1352        else {
1353            $(".optionenInfo").hide();
1354        }
1355
1356        if(page_language == 1){
1357            if(typeof loc_obj[i].c_website_SpeiseoptionenInfo_en !== "undefined" && loc_obj[i].googleAttributes.c_website_SpeiseoptionenInfo_en != ""){
1358                $(".optionenInfo").show().html(loc_obj[i].c_website_SpeiseoptionenInfo_en);
1359            }
1360            else {
1361                $(".optionenInfo").hide();
1362            }
1363        }
1364
1365
1366          //  Öffnungszeiten
1367
1368        //console.log(loc_obj[i]);
1369
1370        if(typeof loc_obj[i].hours !== 'undefined') {
1371            var Today = new Date();
1372            if(useDate != ""){
1373                Today = new Date(useDate);
1374            }
1375            //console.log("Date", Today);
1376            var weekdays = {}
1377            var HolydaysOccuring = false;
1378            var Holydays = {};
1379            var nextdays = {};
1380            var HoursHtmlOutput = "";
1381
1382            var dayNum = {
1383                'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 0,
1384                1: 'monday', 2: 'tuesday', 3: 'wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday', 0: 'sunday'
1385            };
1386
1387            //Unbewegliche Feiertage
1388            const immobileHolydays = {
1389                "23.02.":{"de":"Hans im Glück Tag","en":"Hans im Glück Day"},
1390                "01.01.":{"de":"Neujahr","en":"New Year's Day"},
1391                "06.01.":{"de":"Heilige","en":"Drei Könige	Epiphany"},
1392                "01.05.":{"de":"Tag der Arbeit","en":"Labour Day"},
1393                "03.10.":{"de":"Tag der deutschen Einheit","en":"German Unity Day"},
1394                "15.08.":{"de":"Mariä Himmelfahrt","en":"Assumption Day"},
1395                "01.11.":{"de":"Allerheiligen","en":"All Saints’ Day"},
1396                "25.12.":{"de":"Weihnachtsfeiertag","en":"Christmas Day"},
1397                "26.12.":{"de":"Weihnachtsfeiertag","en":"St Stephens Day"},
1398                "08.03.":{"de":"Internationaler Frauentag","en":"","en":"International Women's Day"},
1399                "08.08.":{"de":"Augsburger Friedensfest","en":"Peace Festival"},
1400                "20.09.":{"de":"Weltkindertag","en":"International Childrens' Day"},
1401                "31.10.":{"de":"Reformationstag","en":"Reformation Day"},
1402                "24.12.":{"de":"Heiliger Abend","en":"Christmas Eve"}
1403            };
1404            const moveableHolydays = {
1405                    0:{"de":"Karfreitag","en":"Good Friday","dates":["10.04.2020","02.04.2021","15.04.2022","07.04.2023","29.03.2024","18.04.2025","03.04.2026"]},
1406                    1:{"de":"Ostersonntag","en":"Easter","dates":["12.04.2020","04.04.2021","17.04.2022","09.04.2023","31.03.2024","20.04.2025","05.04.2026"]},
1407                    2:{"de":"Ostermontag","en":"Easter Monday","dates":["13.04.2020","05.04.2021","18.04.2022","10.04.2023","01.04.2024","21.04.2025","06.04.2026"]},
1408                    3:{"de":"Christi Himmelfahrt","en":"Ascension Day","dates":["21.05.2020","13.06.2021","26.05.2022","18.05.2023","09.05.2024","29.05.2025","14.05.2026"]},
1409                    4:{"de":"Pfingstsonntag","en":"Pentecost","dates":["31.05.2020","23.05.2021","05.06.2022","28.05.2023","19.05.2024","08.06.2025","24.05.2026"]},
1410                    5:{"de":"Pfingstmontag","en":"Whit Monday","dates":["01.06.2020","24.05.2021","06.06.2022","29.05.2023","20.05.2024","09.06.2025","25.05.2026"]},
1411                    6:{"de":"Fronleichnam","en":"Corpus Christi","dates":["11.06.2020","03.06.2021","16.06.2022","08.06.2023","30.05.2024","19.06.2025","04.06.2026"]},
1412                    7:{"de":"Buß- und Bettag","en":"Day of Repentance and Prayer","dates":["18.11.2020","17.11.2021","16.11.2022","22.11.2023","20.11.2024","19.11.2025","18.11.2026"]}
1413            }
1414
1415            function str_pad(n,) {
1416                return String("00" + n).slice(-2);
1417            }
1418
1419            //console.log(immobileHolydays);
1420            //console.log(moveableHolydays);
1421
1422
1423            function processDay(DayData) {
1424                var Response = {'isClosed': false, 'string' : "",'string_last': ""};
1425
1426                //console.log(DayData);
1427
1428                if (typeof DayData.isClosed == 'undefined' || DayData.isClosed == false ) {
1429                    if (typeof DayData.openIntervals !== 'undefined'){
1430                        DayData.openIntervals.forEach(function(thisInterval,IntervalIterator){
1431
1432
1433                            if(IntervalIterator > 0) Response.string += ", ";
1434
1435                            if(IntervalIterator == DayData.openIntervals.length - 1 && typeof thisInterval.end !== 'undefined'){
1436                                Response.string_last = thisInterval.end;
1437                            }
1438
1439                            if (typeof thisInterval.start !== 'undefined' && typeof thisInterval.end !== 'undefined') {
1440                                Response.string += thisInterval.start + " - " + thisInterval.end;
1441                            }
1442                        });
1443
1444                        Response.string = Response.string.replace("23:59","24:00");
1445                        Response.string_last = Response.string_last.replace("23:59","24:00");
1446                        //console.log(Response);
1447                    }
1448                }
1449                else {
1450                    Response.isClosed = true;
1451                    Response.string =  page_language == 1 ? "closed" : "geschlossen";
1452                }
1453
1454                if (typeof DayData.isRegularHours !== 'undefined') Response.isRegularHours = DayData.isRegularHours;
1455
1456                return Response;
1457            }
1458
1459
1460            //Normale Liste der Wochentage vorbereiten
1461            for (let j = 0; j < 7; j++) {
1462                //console.log(dayNum[j]);
1463                if (typeof loc_obj[i].hours[dayNum[j]] !== 'undefined') {
1464                    weekdays[j] = processDay(loc_obj[i].hours[dayNum[j]])
1465                }
1466                weekdays[j].title = weekdaytitles[j];
1467
1468                if (typeof loc_obj[i].c_küchenöffnungszeiten !== 'undefined' && typeof loc_obj[i].c_küchenöffnungszeiten[dayNum[j]] !== 'undefined') {
1469                    weekdays[j].kitchen = processDay(loc_obj[i].c_küchenöffnungszeiten[dayNum[j]])
1470
1471                    weekdays[j].kitchendiffers = weekdays[j].kitchen.string_last == weekdays[j].string_last ? false : true;
1472                } else {
1473                    weekdays[j].kitchendiffers = false
1474                }
1475
1476            }
1477
1478
1479            //Liste der Feiertage Vorbereiten
1480            if (typeof loc_obj[i].hours.holidayHours !== "undefined"){
1481                loc_obj[i].hours.holidayHours.forEach(function(thisHolyday,HolydayIterator){
1482                    if(typeof thisHolyday.date !== "undefined"){
1483                        Holydays[thisHolyday.date] = processDay(thisHolyday);
1484                    }
1485                });
1486            }
1487
1488            //Küchenöffnungszeiten für Feiertage in Liste der Küchenöffnungszeiten integrieren
1489            //Feiertagsküchenöffnungszeiten an Tagen, die keine anderen Feiertagsöffnungszeiten haben werden ignoriert.
1490            if (typeof loc_obj[i].c_küchenöffnungszeiten !== 'undefined' && typeof loc_obj[i].c_küchenöffnungszeiten.holidayHours !== 'undefined') {
1491                loc_obj[i].c_küchenöffnungszeiten.holidayHours.forEach(function(thisHolyday,HolydayIterator){
1492                    if(typeof thisHolyday.date !== "undefined"){
1493                        if(typeof Holydays[thisHolyday.date] !== "undefined"  && typeof Holydays[thisHolyday.date].kitchen !== "undefined") {
1494                            Holydays[thisHolyday.date].kitchen = processDay(thisHolyday);
1495                        }
1496                    }
1497                });
1498            }
1499            //extra checken ob bei den Feiertagen die Küchenöffnungszeiten sich unterscheiden von den normalen
1500            for (thisHolyday in Holydays){
1501                //console.log(thisHolyday);
1502                Holydays[thisHolyday].kitchendiffers = true;
1503
1504                if (typeof Holydays[thisHolyday].kitchen == 'undefined') {
1505                    Holydays[thisHolyday].kitchendiffers = false;
1506                }
1507                else {
1508                    if(Holydays[thisHolyday].kitchen.string_last == Holydays[thisHolyday].string_last || Holydays[thisHolyday].kitchen.isRegularHours){
1509                        Holydays[thisHolyday].kitchendiffers = false;
1510                    }
1511                    else {
1512                        Holydays[thisHolyday].kitchendiffers = true
1513                    }
1514                }
1515
1516            // Checken ob der Feiertag einen Titel hat
1517                var HolydayDate = new Date(thisHolyday);
1518                var HolydayDateString = str_pad(HolydayDate.getDate()) +"." + str_pad(HolydayDate.getMonth() + 1) + ".";
1519                var HolydayDateStringWithYear = str_pad(HolydayDate.getDate()) +"." + str_pad(HolydayDate.getMonth() + 1) + "." + HolydayDate.getFullYear();
1520
1521                //console.log(HolydayDateString, HolydayDateStringWithYear);
1522
1523                //Falls dieser Feiertag in der Liste der Immobilen Feiertage vorkommt
1524                for(immobileHolyday in immobileHolydays){
1525                    //console.log(HolydayDateString, immobileHolyday);
1526                    if(HolydayDateString == immobileHolyday) {
1527                        Holydays[thisHolyday].title = (page_language == 1) ? immobileHolydays[immobileHolyday].en : immobileHolydays[immobileHolyday].de;
1528                    }
1529                }
1530                for(moveableHolyday in moveableHolydays){
1531                    var foundDateOfMoveableHolyday = false;
1532
1533                    moveableHolydays[moveableHolyday].dates.forEac
1533h(function(date){
1534                        //console.log(moveableHolyday, date, HolydayDateStringWithYear);
1535                        if(HolydayDateStringWithYear == date) {
1536                            foundDateOfMoveableHolyday = true;
1537                        }
1538                    });
1539                    if(foundDateOfMoveableHolyday){
1540                        Holydays[thisHolyday].title = (page_language == 1) ? moveableHolydays[moveableHolyday].en : moveableHolydays[moveableHolyday].de;
1541                    }
1542                }
1543            }
1544
1545            //console.log("Wochentage", weekdays);
1546            //console.log("Feiertage", Holydays);
1547
1548            //Checken ob in den nächsten 7 Tagen ein Feiertag ist.
1549            for (let j = 0; j < 7; j++) {
1550                var thisDay = new Date(Today.getTime()+(j*(1000 * 60 * 60 * 24 * 1)));
1551                var thisDayDate = thisDay.getFullYear() + "-" + str_pad(thisDay.getMonth() + 1) + "-" + str_pad(thisDay.getDate());
1552
1553                //console.log(j+1, thisDayDate, Holydays[thisDayDate]);
1554                if(typeof Holydays[thisDayDate]  !== "undefined"){
1555                    HolydaysOccuring = true;
1556                }
1557            }
1558
1559            //console.log("HolydaysOccuring", HolydaysOccuring); // Wurde ein Feiertag gefunden?
1560            // Einblenden des alternativen Titels über den Öffnungszeiten
1561
1562
1563            $("#kitchen_diff").hide();
1564            $("#kitchen_regular").show();
1565
1566            var kitchenHoursDiffer = false;
1567            //Öffnungszeiten ausgeben
1568            for (let j = 0; j < 7; j++) {
1569                var thisDay = new Date(Today.getTime()+(j*(1000 * 60 * 60 * 24 * 1)));
1570                var thisDayDate = thisDay.getFullYear() + "-" + str_pad(thisDay.getMonth() + 1) + "-" + str_pad(thisDay.getDate());
1571
1572                //Falls Feiertag mit eigenem Namen diesen Ausgeben, sonst Wochentagsnamen
1573
1574                if (typeof Holydays[thisDayDate] !== "undefined"){
1575                    nextdays[j] = Holydays[thisDayDate]
1576
1577                    if(typeof Holydays[thisDayDate].title !== "undefined"){
1578                        nextdays[j].title = Holydays[thisDayDate].title;
1579                    } else {
1580                        nextdays[j].title = weekdays[thisDay.getDay()].title;
1581
1582                        // Falls man lieber das Datum anzeigen will.
1583                        //str_pad(thisDay.getDate()) + "." + str_pad(thisDay.getMonth() + 1) + ".";
1584                    }
1585
1586                    if (typeof Holydays[thisDayDate].isRegularHours !== "undefined" && Holydays[thisDayDate].isRegularHours == true) {
1587                        nextdays[j].string = weekdays[thisDay.getDay()].string;
1588                        nextdays[j].string_last = weekdays[thisDay.getDay()].string_last;
1589                    }
1590                }
1591                else {
1592                    nextdays[j] = weekdays[thisDay.getDay()];
1593                }
1594
1595
1596            }
1597
1598            //console.log("Nextdays", nextdays);
1599
1600
1601            //Zeile für Heute geöffnet bis ...
1602            $("#line_open_today").toggle(!nextdays[0].isClosed);
1603            $("#line_kitchen_open_today").hide();
1604            
1605            $("#open_today").text(nextdays[0].string_last);
1606
1607            if(nextdays[0].kitchendiffers){
1608                $("#kitchen_open_today").text(nextdays[0].kitchen.string_last);
1609                $("#line_kitchen_open_today").show();
1610            }
1611
1612
1613            //Ausgabe der nächsten Tage in der Tabelle
1614            for (let j = 0; j < 7; j++) {
1615                HoursHtmlOutput += "<tr><td>";
1616                HoursHtmlOutput += nextdays[j].title
1617                HoursHtmlOutput += "</td><td>";
1618
1619                var regularHours = false;
1620                $("#line_kitchen_open_today").hide();
1621
1622
1623                //Falls das ein Feiertag ist, dann Feiertagsöffnungszeiten ausgeben
1624                HoursHtmlOutput += nextdays[j].string;
1625
1626                if(nextdays[j].kitchendiffers){
1627                    HoursHtmlOutput += " <span class='kitchen'>(" + nextdays[j].kitchen.string_last + ")</span>";
1628                    kitchenHoursDiffer = true;
1629                }
1630
1631                HoursHtmlOutput += "</td></tr>\n";
1632            }
1633
1634            $("#kitchen_headline .kitchen").toggle(kitchenHoursDiffer);
1635            $("#opening_table").html(HoursHtmlOutput);
1636
1637        } //Ende von If, falls Öffnungzeiten nicht in Array vorhanden
1638        else {
1639            $("#opening_table").html("");
1640        }
1641
1642
1643
1644        var currently_closed = false;
1645
1646        if(typeof loc_obj[i].hours !== "undefined" && typeof loc_obj[i].hours.reopenD
1646ate !== "undefined"){
1647
1648        //if (website_status == 'vorübergehend_geschlossen'){
1649            $('#temp_closed').show();
1650            $('.open_today').hide();
1651            currently_closed = true;
1652
1653        } else {
1654            $('#temp_closed').hide();
1655            //$('.open_today').show();
1656        }
1657
1658
1659        //Felder Zum Status "Im Bau"
1660        $(".location-under-construction").hide(); 
1661        $(".construction-title").hide();
1662        $(".construction-copy").hide();
1663        if(typeof loc_obj[i].c_website_hinweis_titel !== "undefined"){
1664            $(".location-under-construction").show();
1665            if(page_language == 1 && typeof loc_obj[i].c_website_hinweis_titel_en !== "undefined"){
1666                var hinweis_title = loc_obj[i].c_website_hinweis_titel_en;
1667            } else {
1668                var hinweis_title = loc_obj[i].c_website_hinweis_titel;
1669            }
1670            $(".construction-title").show().text(hinweis_title);
1671        }
1672
1673        if(typeof loc_obj[i].c_website_hinweis_copy !== "undefined"){
1674            $(".location-under-construction").show();
1675            if(page_language == 1 && typeof loc_obj[i].c_website_hinweis_copy_en !== "undefined"){
1676                var hinweis_copy = loc_obj[i].c_website_hinweis_copy_en;
1677            } else {
1678                var hinweis_copy = loc_obj[i].c_website_hinweis_copy;
1679            }
1680            $(".construction-copy").show().html(hinweis_copy);
1681        }
1682
1683        $(".button-call").removeClass("disabled");
1684        if(typeof loc_obj[i].mainPhone !== "undefined" && website_status != 'im_bau'){
1685            var Phone = loc_obj[i].mainPhone;
1686
1687            $("#link_phone").text(Phone);
1688            $("#link_phone").attr("href","tel:" + Phone);
1689            $(".button-call").attr("href","tel:" + Phone);
1690            $("#line_phone").show();
1691
1692        } else {
1693            $("#line_phone").hide();
1694        }
1695
1696        if(website_status == 'im_bau'){
1697            $("#coming_soon").show();
1698            $(".button-call").addClass("disabled");
1699
1700            currently_closed = true;
1701        } else {
1702            $("#coming_soon").hide();
1703            $("#kitchen_headline, #opening_table").show();
1704        }
1705
1706        $("#kitchen_headline, #opening_table").toggle(!currently_closed);
1707        if(currently_closed){
1708            $("#line_open_today,#line_kitchen_open_today").hide();
1709        }
1710
1711
1712
1713        var RouteCoords;
1714        var ThisPlacesId = "";
1715        if(typeof loc_obj[i].googlePlaceId !== "undefined"){
1716
1717            ThisPlacesId = loc_obj[i].googlePlaceId;
1718        }
1719        if(typeof loc_obj[i].yextDisplayCoordinate ||  typeof loc_obj[i].yextRoutableCoordinate !== "undefined"){
1720            if(typeof loc_obj[i].yextDisplayCoordinate !== "undefined") {
1721                RouteCoords = {lat: loc_obj[i].yextDisplayCoordinate.latitude, lng: loc_obj[i].yextDisplayCoordinate.longitude};
1722            }
1723            if(typeof loc_obj[i].yextRoutableCoordinate !== "undefined") {
1724                RouteCoords = {lat: loc_obj[i].yextRoutableCoordinate.latitude, lng: loc_obj[i].yextRoutableCoordinate.longitude};
1725            }
1726            $(".button-route").attr("href","https://www.google.com/maps/dir/?api=1&destination="+ RouteCoords.lat  +"%2C" + RouteCoords.lng + "&destination_place_id="+ ThisPlacesId);
1727            $(".button-route").show();
1728        }
1729        else {
1730            $(".button-route").hide();
1731        }
1732
1733
1734        $(".button-order").removeClass("disabled");
1735        if(typeof loc_obj[i].c_website_lieferserivce !== "undefined" && loc_obj[i].c_website_lieferserivce != ""){
1736            $(".button-order").attr("href",loc_obj[i].c_website_lieferserivce);
1737        }
1738        else {
1739            $(".button-order").addClass("disabled");
1740        }
1741
1742
1743        $(".location-details").attr("data-YextId",loc_obj[i].meta.id);
1744        $(".location-details").attr("data-id",i);
1745
1746
1747        $(".button-fav").removeClass("active");
1748        if(loc_obj[i].meta.id == $.cookie('favorite-yextid')) {
1749            $(".button-fav").addClass("active");
1750        }
1751
1752
1753        $(".button-fav").attr("data-YextId",loc_obj[i].meta.id);
1754
1755        $("#link_speisekarte").show();
1756        $("#link_address_speisekarte").show();
1757
1758
1759
1760
1761        var menuUrlField = "c_website_menu_de";
1762        var menuUrl = "/fileadmin/Dokumente/Speisekarten/";
1763        var menuUrlLanguageFolder = "de/";
1764        if(page_language == 1){
1765            menuUrlField = "c_website_menu_en";
1766            menuUrlLanguageFolder = "en/";
1767        }
1768        if(typeof loc_obj[i][menuUrlField] !== "undefined") {
1769            const yextlink = loc_obj[i][menuUrlField];
1770			if (yextlink.includes('pdf')) $("#link_speisekarte, #link_address_speisekarte").attr("href",menuUrl + menuUrlLanguageFolder + yextlink);
1771			else $("#link_speisekarte, #link_address_speisekarte").attr("href",yextlink);
1772        }
1773        else {
1774            $("#link_speisekarte, #link_address_speisekarte").hide();
1775        }
1776
1777
1778        if(Array.isArray(loc_obj[i].emails)){
1779            $("#link_mail").text(loc_obj[i].emails[0]);
1780            $("#link_mail").attr("href", "mailto:" + loc_obj[i].emails[0]);
1781            $("#line_mail").show();
1782        } else {
1783            $("#line_mail").hide();
1784        }
1785
1786        var DistanceString = DistanceToText(loc_obj[i].loc_distance);
1787        //console.log("DistanceString", DistanceString);
1788        if(DistanceString !== undefined && DistanceString != ""){
1789            $("#distance").text(DistanceToText(loc_obj[i].loc_distance));
1790        }
1791
1792
1793        higpage.currentMarker = marker;
1794        map.setCenter(marker.position);
1795        map.setZoom(14);
1796
1797
1798        //#### Standortliste ###
1799        $(".location-jobs").hide();
1800        bewerben_text = bewerben_text.trim();
1801
1802        $(".location-jobs ul li").remove();
1803        var yextid = loc_obj[i].meta.id || 0;
1804        var jobs = $("#location-joblist .jobs-list-item[data-location_yextid=" + yextid + "]");
1805
1806        //console.log("Jobs für diesen Standort " + jobs.length);
1807
1808        if(jobs.length){
1809            $(jobs).each(function(){
1810
1811                var jobtyp = $(this).attr("data-jobtyp_titel");
1812                var link = $(this).find(".link-wrapper a").attr("href");
1813                var link_target = $(this).find(".link-wrapper a").attr("target") ? $(this).find(".link-wrapper a").attr("target") : "_self" ;
1814
1815                var job_entry = "<li><strong>" + jobtyp + "</strong>" +
1816                    "<div class='link-wrapper'><a href='" + link + "' target='" + link_target + "'>" + bewerben_text + "</a>" +
1817                    "</div></li>";
1818
1819                $(".location-jobs ul").append(job_entry);
1820
1821
1822            });
1823
1824            $(".location-jobs").show();
1825
1826        }
1827
1828
1829
1830
1831
1832        if($(".r-tablet:visible").length){ //Tablet
1833            $("#location-overlay").insertBefore($(".location-list"));
1834            $(".location-list").slideUp();
1835
1836            $("#location-overlay").slideDown(300);
1837
1838
1839        } else if($(".r-mobile:visible").length){ //Mobile
1840            setTimeout(function(){$("#location-overlay").insertBefore($(".location-list"));},10);
1841
1842            //console.log("#location-overlay.length", $("#location-overlay").length);
1843            //console.log(".location-list.length", $(".location-list").length);
1844            $(".location-list").slideUp();
1845            $(".location-top").slideUp();
1846
1847            $("#location-overlay").slideDown(300);
1848
1849
1850        } else { 
1851            //console.log("Yes, its Desktop", marker);
1852
1853            //mapDetails.setCenter(marker.position);
1854            //mapDetails.setZoom(15);
1855
1856            $("#location-overlay").fadeIn(300);
1857        }
1858
1859        if(urlhash == '#stellen') {
1860          if ($(".r-mobile:visible").length) {
1861            setTimeout(function(){
1862              scrollTop($(".location-jobs").offset().top - 65, 600);
1863            },30);
1864    		  } else {
1865            scrollTop($(".location-jobs").offset().top - 80, 500);
1866    			}
1867
1868        }
1869        
1870        $(window).trigger("resize");
1871        
1872        */
1873
1874    }
1875    catch(e) {
1876        console.log("Fehler in OpenLocation()",e);
1877    }
1878}
1879
1880function CloseLocation(changepushstate = true){
1881    if($(".r-desktop:visible").length) {
1882
1883        $("#location-overlay").fadeOut(300,function(){
1884            $("#location-overlay").insertAfter($("article"));
1885        });
1886
1887    } else {
1888        $("#location-overlay").slideUp(300,function(){
1889            $("#location-overlay").insertAfter($("article"));
1890        });
1891    }
1892
1893    if(changepushstate){
1894        window.history.pushState({status: "close"}, "", languageSlug + page_slug);
1895    }
1896
1897
1898    $(".location-list").slideDown();
1899    $(".location-top").slideDown();
1900
1901    /* Wie ein Refresh, weil Marker unsichtbar war*/
1902    var MapZoom = map.getZoom();
1903    map.setZoom(MapZoom-1);map.setZoom(MapZoom);
1904
1905    $(window).trigger("resize");
1906
1907}
1908
1909function handleShowDeliveries(event) {
1910    event.preventDefault();
1911    var $deliveryBtn = $(event.srcElement);
1912    var deliveryLinks = $deliveryBtn.data();
1913    $deliveryBtn.parent().find(".gm-cta").hide();
1914    var copy = i18nHIG.deliveryQuestion + "<br>";
1915    var cta1 = '<a class="gm-cta" href="' + deliveryLinks.target1 + '"target="_blank">Deliveroo</a>';
1916    var cta2 = '<a class="gm-cta" href="' + deliveryLinks.target2 + '"target="_blank">Lieferando</a>';
1917    $deliveryBtn.parent().append(copy);
1918    $deliveryBtn.parent().append(cta1);
1919    $deliveryBtn.parent().append(cta2);
1920    $deliveryBtn.parent().find(".show-deliveries").remove()
1921}
1922
1923
1924
1925/* ==========================================================================
1926    Helper Funktionen
1927   ========================================================================== */
1928
1929function rad(x) {
1930    return x * Math.PI / 180
1931}
1932
1933function compareValues(key, order = 'asc') {
1934    return function innerSort(a, b) {
1935
1936        if (key.indexOf(".") > -1) {
1937            keys = key.split(".");
1938
1939            if (!a[keys[0]].hasOwnProperty(keys[1]) || !b[keys[0]].hasOwnProperty(keys[1])) {
1940                // property doesn't exist on either object
1941                return 0;
1942            }
1943
1944            var varA = (typeof a[keys[0]][keys[1]] === 'string')
1945                ? a[keys[0]][keys[1]].toUpperCase() : a[keys[0]][keys[1]];
1946            var varB = (typeof b[keys[0]][keys[1]] === 'string')
1947                ? b[keys[0]][keys[1]].toUpperCase() : b[keys[0]][keys[1]];
1948
1949
1950        } else {
1951
1952            if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
1953                // property doesn't exist on either object
1954                return 0;
1955            }
1956
1957            var varA = (typeof a[key] === 'string')
1958                ? a[key].toUpperCase() : a[key];
1959            var varB = (typeof b[key] === 'string')
1960                ? b[key].toUpperCase() : b[key];
1961
1962        }
1963
1964        let comparison = 0;
1965        if (varA > varB) {
1966            comparison = 1;
1967        } else if (varA < varB) {
1968            comparison = -1;
1969        }
1970        return (
1971            (order === 'desc') ? (comparison * -1) : comparison
1972        );
1973
1974
1975
1976    };
1977}
1978
1979function DistanceToText(distance){
1980    var Result = "";
1981    Result = Math.round(distance * 100) / 100;
1982    Result = Result > 10 ? Math.round(Result) : Math.round(Result * 10) / 10;
1983    Result = Result < 1 ? (Result * 1000) + "m" : Result + "km";
1984
1985    return Result;
1986}
1987
1988function initStandortMap(){
1989
1990    $('#details-google-map-holder').on('click', function () { 
1991        UC_UI.showSecondLayer();
1992    });
1993
1994	if (!document.getElementById("details-google-map-holder"))
1995		return;
1996
1997	if (typeof google !== 'object') 
1998		return;
1999
2000	if(typeof standortLatitude !== 'undefined'){
2001		mapObject.disableDefaultUI = true;
2002		mapObject.draggable = false;
2003		mapDetails = new google.maps.Map(document.getElementById("details-google-map-holder"), mapObject);
2004		
2005		var standort_icon = {
2006        url: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg id='Ellipse_123' data-name='Ellipse 123' fill='%23fff' stroke='%23dcd500' stroke-width='1'%3E%3Ccircle cx='12' cy='12' r='12' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='11.5' fill='none'/%3E%3C/g%3E%3C/svg%3E%0A",
2007        size: new google.maps.Size(24, 24),
2008        origin: new google.maps.Point(0, 0),
2009        anchor: new google.maps.Point(12, 12)
2010    };
2011    
2012		marker = new google.maps.Marker({
2013			position: {
2014				lat: standortLatitude,
2015				lng: standortLongitude
2016			},
2017			map: mapDetails,
2018			title: standortName,
2019			icon: standort_icon,
2020			animation: google.maps.Animation.DROP
2021		});
2022		
2023		
2024		mapDetails.setCenter(marker.position);
2025		mapDetails.setZoom(14);
2026
2027        google.maps.event.addListenerOnce(mapDetails, 'idle', function(){
2028            // remove click event from #google-map-holder
2029            $('#details-google-map-holder').off('click');
2030            
2031        });
2032		
2033	}
2034}
2035
2036function initStandort(){
2037	if (!document.getElementById("details-google-map-holder"))
2038		return;
2039
2040    //if (typeof google !== 'object') 
2041	//	return;
2042
2043	
2044	if(typeof standortId !== 'undefined'){
2045		
2046		// init standort map
2047		if ($("#details-google-map-holder").length > 0) {
2048      
2049	        //google.maps.event.addDomListener(window, 'load', initStandortMap);
2050	        
2051	
2052	        if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Safari") > 0) {
2053	            setTimeout(function(){
2054	                initStandortMap();
2055	            }, 500);
2056	        } else {
2057		    	window.addEventListener('load',initStandortMap);    
2058	        }
2059		}
2060		
2061		
2062		// progress jobs
2063		$(".location-jobs").hide();
2064		$(".jobs, h2.r-mobile-not").hide();
2065        bewerben_text = bewerben_text.trim();
2066        $(".location-jobs ul li").hide();
2067        var jobs = $(".jobs-list .jobs-list-item[data-location_yextid=" + standortId + "]");
2068
2069        if(jobs.length){
2070
2071            if (console && console.log) {
2072                //console.log("Jobs für diesen Standort " + jobs.length);
2073            }
2074
2075            $(jobs).each(function(){
2076                var jobtyp = $(this).attr("data-jobtyp_titel");
2077                var link = $(this).find(".link-wrapper a").attr("href");
2078                var locTitle = $(this).find(".prop-city").text();
2079                var link_target = $(this).find(".link-wrapper a").attr("target") ? $(this).find(".link-wrapper a").attr("target") : "_self" ;
2080                var job_entry = "<li><strong>" + jobtyp + "</strong>" + locTitle +
2081                    "<div class='link-wrapper'><a href='" + link + "' target='" + link_target + "'>" + bewerben_text + "</a>" +
2082                    "</div></li>";
2083                $(".location-jobs ul").append(job_entry);
2084            });
2085            $(".location-jobs").show();
2086        }
2087        
2088        // hashy scrolly
2089        if (page_arguments.length == 1){
2090	        var urlhash = page_arguments[0];
2091	        if(urlhash == '#stellen') {
2092				if ($(".r-mobile:visible").length) {
2093					setTimeout(function(){
2094					scrollTop($(".location-jobs").offset().top - 65, 600);
2095					},30);
2096				} else {
2097					scrollTop($(".location-jobs").offset().top - 75, 800);
2098				}
2099	        }
2100        }
2101
2102	}
2103}
2104initStandort();
2105
2106
2107function initGroupMap(){
2108	if (!document.getElementById("group-map-holder"))
2109		return;
2110
2111    if (typeof google !== 'object') 
2112		return;
2113
2114    loc_length = group_obj.length;
2115    markers = [];
2116    infowindows = [];
2117
2118    map = new google.maps.Map(document.getElementById("group-map-holder"), mapObject);
2119
2120    mapObject.disableDefaultUI = true;
2121    mapObject.draggable = false;
2122
2123    /*window.higfunc.map = map;*/
2124    myLatLng = {
2125        lat: higpage.defaultPosition.lat,
2126        lng: higpage.defaultPosition.lng
2127    };
2128    map.setZoom(10);
2129    map.setCenter(myLatLng);
2130    var location_icon = {
2131        url: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg id='Ellipse_123' data-name='Ellipse 123' fill='%23fff' stroke='%23dcd500' stroke-width='1'%3E%3Ccircle cx='12' cy='12' r='12' stroke='none'/%3E%3Ccircle cx='12' cy='12' r='11.5' fill='none'/%3E%3C/g%3E%3C/svg%3E%0A",
2132        size: new google.maps.Size(24, 24),
2133        origin: new google.maps.Point(0, 0),
2134        anchor: new google.maps.Point(12, 12)
2135    };
2136    
2137    infowindow = new google.maps.InfoWindow;
2138    contentStrings = [];
2139    contentStringsExt = [];
2140    var onclickeventStr = "";
2141    var onclickevent = "";
2142    var yids = [];
2143
2144
2145    $("#group-map-holder").css("opacity",1);
2146
2147    /* Alle Marker Erstellen */
2148    for (var i = 0; i < loc_length; i++) {
2149
2150	    yids.push(parseInt(group_obj[i].yextID));
2151        var icontoSet = location_icon;
2152        
2153        marker = new google.maps.Marker({
2154            position: {
2155                lat: group_obj[i].yextDisplayCoordinate.latitude,
2156                lng: group_obj[i].yextDisplayCoordinate.longitude
2157            },
2158            title: group_obj[i].city,
2159            icon: icontoSet
2160        });
2161        
2162        yextID = group_obj[i].yextID;
2163
2164        google.maps.event.addListener(marker, "click", function(marker, yextID) {
2165            return function () {
2166                OpenLocation(marker,yextID);
2167            }
2168        }(marker, yextID));
2169
2170        markers.push(marker);
2171    }
2172    
2173    var markerCluster = new MarkerClusterer(map, markers, {
2174        minimumClusterSize: 5,
2175        /*imagePath: stylesheet_directory_uri + "/images/base/googlemaps/m",*/
2176        styles: clusterStyles
2177    });
2178    
2179    map.setCenter(markers[0].position);
2180
2181    /*google.maps.event.addDomListener(window, "resize", function() {
2182        var center = map.getCenter();
2183        google.maps.event.trigger(map, "resize");
2184        map.setCenter(center)
2185    });*/
2186    window.addEventListener('resize',function() {
2187        var center = map.getCenter();
2188        google.maps.event.trigger(map, "resize");
2189        map.setCenter(center)
2190    });
2191    
2192    
2193    // progress jobs
2194		$(".location-jobs").hide();
2195		$(".jobs, h2.r-mobile-not").hide();
2196        bewerben_text = bewerben_text.trim();
2197        $(".location-jobs ul li").hide();
2198        //var jobs = $(".jobs-list .jobs-list-item[data-location_yextid=" + standortId + "]");
2199        
2200        var jobs = $(".jobs-list .jobs-list-item").filter(function(){
2201	        return $.inArray($(this).data('location_yextid'), yids) > -1
2202		});
2203		
2204        if(jobs.length){
2205            $(jobs).each(function(){
2206	            
2207	            var jobtyp = $(this).attr("data-jobtyp_titel");
2208                var link = $(this).find(".link-wrapper a").attr("href");
2209                var locTitle = $(this).find(".prop-city").text();
2210                var link_target = $(this).find(".link-wrapper a").attr("target") ? $(this).find(".link-wrapper a").attr("target") : "_self" ;
2211                var job_entry = "<li><strong>" + jobtyp + "</strong>" + locTitle + 
2212                    "<div class='link-wrapper'><a href='" + link + "' target='" + link_target + "'>" + bewerben_text + "</a>" +
2213                    "</div></li>";
2214                $(".location-jobs ul").append(job_entry);
2215            });
2216            $(".location-jobs").show();
2217            $(".location-jobs li.jobs-loading").remove();
2218        }
2219
2220}
2221
2222function initGroupJobs(){
2223	if (!group_obj)
2224		return;
2225	
2226    $(".location-jobs ul li, .location-jobs > h4, .location-jobs .content-block.cb-100.cb-button").remove();
2227    //$(".location-jobs").hide();
2228    $(".location-jobs ul").append('<li class="jobs-loading"></li>');
2229    $(".jobs, h2.r-mobile-not").hide();
2230    bewerben_text = bewerben_text.trim();
2231    
2232        
2233	loc_length = group_obj.length;
2234    
2235    var yids = [];
2236
2237    /* Alle Marker Erstellen */
2238    for (var i = 0; i < loc_length; i++) {
2239	    yids.push(parseInt(group_obj[i].yextID));
2240    }
2241    
2242    // progress jobs
2243    //var jobs = $(".jobs-list .jobs-list-item[data-location_yextid=" + standortId + "]");
2244    var jobs = $(".jobs-list .jobs-list-item").filter(function(){
2245        return $.inArray($(this).data('location_yextid'), yids) > -1
2246    });
2247    
2248    // Sort jobs by TYPE (data-jobtyp_titel)
2249    jobs.sort((a, b) => a.attributes[5].nodeValue.localeCompare(b.attributes[5].nodeValue))
2250    
2251    if(jobs.length){
2252        $(jobs).each(function(){
2253            var jobtyp = $(this).attr("data-jobtyp_titel");
2254            var link = $(this).find(".link-wrapper a").attr("href");
2255            var locTitle = $(this).find(".prop-city").text();
2256            var link_target = $(this).find(".link-wrapper a").attr("target") ? $(this).find(".link-wrapper a").attr("target") : "_self" ;
2257            var job_entry = "<li><strong>" + jobtyp + "</strong>" + locTitle + 
2258                "<div class='link-wrapper'><a href='" + link + "' target='" + link_target + "'>" + bewerben_text + "</a>" +
2259                "</div></li>";
2260            $(".location-jobs ul").append(job_entry);
2261        });
2262        //$(".location-jobs").show();
2263        $(".location-jobs li.jobs-loading").remove();
2264    }
2265
2266}
2267
2268/* newsletter autofill */ 
2269window.addEventListener('load', (event) => { initNewsletterAC(); });
2270async function initNewsletterAC() {
2271	if ($('.form-zip').length < 1) return;
2272	if (!navigator.geolocation) return;
2273	if (typeof google !== 'object') return;
2274
2275	await google.maps.importLibrary("geocoding");
2276
2277	const geocoder = new google.maps.Geocoder();
2278
2279	const permission = await navigator.permissions.query({ name: 'geolocation' });
2280	if (permission.state !== 'granted') return;
2281
2282	navigator.geolocation.getCurrentPosition(
2283		(position) => {
2284			const latLng = {
2285				lat: position.coords.latitude,
2286				lng: position.coords.longitude
2287			};
2288
2289			geocoder.geocode({ location: latLng }, (results, status) => {
2290				if (status !== "OK" || !results[0]) return;
2291
2292				for (const component of results[0].address_components) {
2293					const componentType = component.types[0];
2294					switch (componentType) {
2295						case "postal_code":
2296							$('.form-zip').val(component.long_name);
2297							break;
2298						case "locality":
2299							$('.form-city').val(component.long_name);
2300							break;
2301						case "administrative_area_level_1":
2302							$('.form-state').val(component.long_name);
2303							break;
2304						case "country":
2305							$('.form-country').val(component.long_name);
2306							break;
2307					}
2308				}
2309			});
2310		},
2311		(error) => {
2312			console.log("[NewsletterAC] geolocation denied or failed:", error.message);
2313		},
2314		{ timeout: 10000 }
2315	);
2316}
2317

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.