PageSourceSearch

https://mosler-immobilien.de/wp-content/plugins/frymo/inc/elementor/assets/js/frymo-wishlist.js?ver=1.30.0

js mosler-immobilien.de collected 2026-10-07 05:10:15 UTC 3,617 bytes, 86 lines download raw bytes

1jQuery(window).on('elementor/frontend/init', () => {
2    // Helper: Retrieve cookie value by name and parse it as JSON (default to an empty array)
3    const getCookie = (name) => {
4        const nameEQ = `${name}=`;
5        return document.cookie.split(';').reduce((acc, cookieStr) => {
6            const cookie = cookieStr.trim();
7            if (cookie.indexOf(nameEQ) === 0) {
8                try {
9                    return JSON.parse(decodeURIComponent(cookie.substring(nameEQ.length)));
10                } catch (e) {
11                    return [];
12                }
13            }
14            return acc;
15        }, []);
16    };
17
18    // Helper: Get the post ID from an element or its closest .frymo-favorite parent
19    const getPostId = (element) => {
20        if (element.classList.contains('frymo-favorite')) {
21            return element.getAttribute('data-post-id');
22        }
23        const parent = element.closest('.frymo-favorite');
24        return parent ? parent.getAttribute('data-post-id') : null;
25    };
26
27    // Helper: Toggle the favorite button text class for all buttons
28    const toggleFavoriteButtonText = () => {
29        document.querySelectorAll('.frymo-favorite .elementor-button-text')
30            .forEach(btn => btn.classList.toggle('frymo-favorite-remove'));
31    };
32
33    // Mark favorite buttons as "favorited" based on stored cookie
34    const favoritePosts = getCookie('frymo_favorites');
35    if (favoritePosts.length) {
36        favoritePosts.forEach(postId => {
37            document.querySelectorAll(`.frymo-favorite[data-post-id="${postId}"]`)
38                .forEach(button => button.classList.add('is--favorited'));
39        });
40        toggleFavoriteButtonText();
41    }
42
43    // Wishlist handler for Elementor
44    const FRYMWishListHandler = ($scope) => {
45        $scope.on('click', '.frymo-favorite', function (e) {
46            e.preventDefault();
47
48            const postId = getPostId(e.target);
49            const favorites = getCookie('frymo_favorites') || [];
50            const isFavorited = toggleFavoriteStatus(favorites, postId);
51
52            updateFavoriteUI(this, isFavorited);
53            setCookie('frymo_favorites', favorites, 30);
54            applyGloriousEffect(this);
55        });
56
57        // Toggle the favorite status in the array and return the new state
58        const toggleFavoriteStatus = (favorites, postId) => {
59            const index = favorites.indexOf(postId);
60            if (index === -1) {
61                favorites.push(postId);
62                return true;
63            }
64            favorites.splice(index, 1);
65            return false;
66        };
67
68        // Update the UI based on favorite status and adjust button text
69        const updateFavoriteUI = (element, isFavorited) => {
70            element.classList.toggle('is--favorited', isFavorited);
71            toggleFavoriteButtonText();
72        };
73
74        // Add a temporary "glorious" effect
75        const applyGloriousEffect = (element) => {
76            element.classList.add('glorious');
77            setTimeout(() => element.classList.remove('glorious'), 700);
78        };
79    };
80
81    // Register the handler for different Elementor widget hooks
82    elementorFrontend.hooks.addAction('frontend/element_ready/frymo-listing.grid-skin', FRYMWishListHandler);
83    elementorFrontend.hooks.addAction('frontend/element_ready/frymo-listing.list-skin', FRYMWishListHandler);
84    elementorFrontend.hooks.addAction('frontend/element_ready/frymo-wishlist.wishlist-skin', FRYMWishListHandler);
85    elementorFrontend.hooks.addAction('frontend/element_ready/frymo-wishlist-item.default', FRYMWishListHandler);
86});

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.