PageSourceSearch

https://physiogel.de/media/zwetschke/js/apofinder.js?d573fe

js physiogel.de collected 2026-10-04 21:44:51 UTC 4,983 bytes, 156 lines download raw bytes

1/**
2 * @link   http://zwetschke.de
3 * @author Zwetschke Team <[email protected]>
4 *
5 * Copyright (c) 2024 zwetschke GmbH & Co. KG
6 */
7;(function (window, document) {
8    "use strict";
9
10    const WIDGET_ID = 'apo-finder-widget';
11    const SNIPPET_SRC = 'https://ihreapotheken.de/widget/build/apofinder-v2/snippet.min.js';
12
13    let snippetPromise = null;
14
15    const config = {
16        base: {
17            widgetBase: 'https://ihreapotheken.de',
18            apiBase: 'https://ihreapotheken.de',
19            apiBaseElastic: 'https://api.ia.de'
20        },
21        parameters: {
22            headline: 'Apotheken vor Ort',
23            text: 'Wählen Sie Ihre Apotheke vor Ort und bestellen Sie ganz einfach zur Abholung oder per Botendienst-Lieferung.',
24            view: 'list',
25            pharmaciesPerPage: 5,
26            showAllPharmacies: true,
27            showAllPharmaciesFilter: true,
28            geolocation: true,
29            showGoogleMap: true,
30            needsGoogleConsent: true,
31            consentActive: true,
32            openLinksInNewWindow: true,
33            hideMagazines: true
34        }
35    };
36
37    let $modal = null;
38    let $widget = null;
39
40    const buildModal = () => {
41        $modal = document.createElement('div');
42        $modal.className = 'apo-finder-modal';
43
44        const $dialog = document.createElement('div');
45        $dialog.className = 'apo-finder-dialog';
46
47        const $close = document.createElement('button');
48        $close.type = 'button';
49        $close.className = 'apo-finder-close';
50        $close.setAttribute('aria-label', 'Schließen');
51        $close.innerHTML = '&times;';
52
53        $widget = document.createElement('div');
54        $widget.id = WIDGET_ID;
55        $widget.className = 'apo-finder-widget';
56
57        $dialog.appendChild($close);
58        $dialog.appendChild($widget);
59        $modal.appendChild($dialog);
60        document.body.appendChild($modal);
61
62        $close.addEventListener('click', closeModal);
63        $modal.addEventListener('click', (e) => {
64            if (e.target === $modal) closeModal();
65        });
66        document.addEventListener('keydown', (e) => {
67            if (e.key === 'Escape') closeModal();
68        });
69    };
70
71    const loadSnippet = () => {
72        if (window.ApoFinderWidget) return Promise.resolve();
73        if (snippetPromise) return snippetPromise;
74
75        snippetPromise = new Promise((resolve, reject) => {
76            const $script = document.createElement('script');
77            $script.src = SNIPPET_SRC;
78            $script.defer = true;
79            $script.addEventListener('load', resolve);
80            $script.addEventListener('error', reject);
81            document.body.appendChild($script);
82        });
83
84        return snippetPromise;
85    };
86
87    const hasMarketingConsent = () => {
88        return !!(window.Cookiebot && window.Cookiebot.consent && window.Cookiebot.consent.marketing);
89    };
90
91    const renderWidget = () => {
92        loadSnippet().then(() => {
93            if (!window.ApoFinderWidget) return;
94            $widget.innerHTML = '';
95            new window.ApoFinderWidget(WIDGET_ID, config);
96        });
97    };
98
99    const renderConsentMessage = () => {
100        $widget.innerHTML = '';
101
102        const $message = document.createElement('div');
103        $message.className = 'apo-finder-consent';
104
105        const $text = document.createElement('p');
106        $text.textContent = 'Für die Apothekensuche ist Ihre Einwilligung in die Cookie-Kategorie „Marketing“ erforderlich. Bitte stimmen Sie zu, um den Apothekenfinder zu nutzen.';
107
108        const $button = document.createElement('button');
109        $button.type = 'button';
110        $button.className = 'button';
111        $button.textContent = 'Einwilligung anpassen';
112        $button.addEventListener('click', () => {
113            if (window.Cookiebot && typeof window.Cookiebot.renew === 'function') {
114                window.Cookiebot.renew();
115            }
116        });
117
118        $message.appendChild($text);
119        $message.appendChild($button);
120        $widget.appendChild($message);
121    };
122
123    const openModal = () => {
124        if (!$modal) buildModal();
125
126        if (hasMarketingConsent()) {
127            renderWidget();
128        } else {
129            renderConsentMessage();
130        }
131
132        $modal.classList.add('is-open');
133        document.body.classList.add('apo-finder-open');
134    };
135
136    const closeModal = () => {
137        if (!$modal) return;
138        $modal.classList.remove('is-open');
139        document.body.classList.remove('apo-finder-open');
140        $widget.innerHTML = '';
141    };
142
143    document.addEventListener('click', (e) => {
144        const $button = e.target.closest('.apo-finder-button');
145        if (!$button) return;
146        e.preventDefault();
147        openModal();
148    });
149
150    window.addEventListener('CookiebotOnAccept', () => {
151        if ($modal && $modal.classList.contains('is-open') && hasMarketingConsent()) {
152            renderWidget();
153        }
154    });
155
156})(window, document);

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.