PageSourceSearch

https://restproperty.com/template/main/web/js/catalog-elements.js

js restproperty.com collected 2026-10-08 01:27:09 UTC 1,814 bytes, 39 lines download raw bytes

1document.querySelector('body').addEventListener('click', async (event) => {
2    // Определяем, на какую кнопку было нажато
3    const target = event.target.closest('.js-realty-wishlist, .js-realty-compare');
4    if (!target) return;
5
6    // Получаем данные для отправки запроса
7    const id = target.dataset.model;
8    const active = target.classList.contains('active');
9    const formData = new FormData();
10    formData.append('id', id);
11
12    // Определяем URL на основе типа кнопки и состояния
13    const isWishlist = target.classList.contains('js-realty-wishlist');
14    const url = isWishlist ? (active ? '/favorites/remove/' : '/favorites/add/') : (active ? '/compare/remove/' : '/compare/add/');
15
16    // Отправляем запрос
17    try {
18        const response = await fetch(url, {
19            method: 'POST',
20            headers: { 'X-Requested-With': 'XMLHttpRequest' },
21            body: formData
22        });
23
24        if (response.ok) {
25            const data = await response.json();
26            if (data.status === "success") {
27                // Обновляем иконку и класс в зависимости от состояния
28                const icon = isWishlist ? (active ? '#heart' : '#heart-fill') : (active ? '#compare' : '#compare');
29                target.querySelector('svg').innerHTML = `<use xlink:href="${icon}"></use>`;
30                target.classList.toggle('active');
31                target.classList.toggle('text-secondary');
32            }
33        } else {
34            console.error('Ошибка при запросе:', response.status, response.statusText);
35        }
36    } catch (error) {
37        console.error('Ошибка сети:', error);
38    }
39});

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.