PageSourceSearch

https://saratovdrama.com/local/templates/drama_2020/components/bit…/script.js?17709770499760

js saratovdrama.com collected 2026-10-03 23:15:50 UTC 9,760 bytes, 253 lines download raw bytes

1$(function () {
2    setEmptyResult();
3    var afishaMonth = BX.localStorage.get('afishaMonth');
4    console.log('afishaMonth');
5    console.log(afishaMonth);
6    if (afishaMonth) {
7        $(document).find('.afishaBtnsMonth [data-monthbtn="' + afishaMonth + '"]').click();
8    } else {
9        $(document).find('.afishaBtnsMonth [data-monthbtn]:first').click();
10    }
11
12    $('.afishaHead a').on('click', function (e) {
13        e.preventDefault();
14        let href = $(this).attr('href');
15        $('.afishaHead .nav-link').removeClass('active');
16        $(this).addClass('active');
17        $.post('/ajax/setCookies.php', {'scena': href}, function (data) {
18            //console.log(data);
19        })
20        if (href) {
21            $('.tab-content .tab-pane').removeClass('active');
22            $('#' + href).addClass('active');
23            setEmptyResult();
24
25        }
26    });
27
28});
29
30
31$(document).ready(function() {
32    
33  /*   // Сначала объявляем ВСЕ функции
34    function getBitrixSessid() {
35        if (typeof BX !== 'undefined' && BX.bitrix_sessid) {
36            return BX.bitrix_sessid();
37        }
38        const meta = document.querySelector('meta[name="bitrix-sessid"]');
39        return meta ? meta.content : '';
40    }
41    
42    getRadarioStat = async function(eventIds) {
43        const sessid = getBitrixSessid(); 
44        try {
45            const response = await fetch('/ajax/radario_places.php', {
46                method: 'POST',
47                headers: {
48                    'Content-Type': 'application/json',
49                },
50                body: JSON.stringify({ 
51                    event_ids: eventIds,
52                    sessid: sessid 
53                })
54            });
55            
56            if (!response.ok) {
57                throw new Error(`HTTP error! status: ${response.status}`);
58            }
59            
60            const text = await response.text();
61            
62            try {
63                return JSON.parse(text);
64            } catch (e) {
65                console.error('Ответ не является валидным JSON:', text.substring(0, 200));
66                throw new Error('Сервер вернул некорректный JSON');
67            }
68        } catch (error) {
69            console.error('Ошибка при получении статистики:', error);
70            throw error;
71        }
72    }
73    
74    function updatePlaces(data) {
75		   console.warn('updatePlaces');
76        if (data.events && Array.isArray(data.events)) {
77            $.each(data.events, function(index, event) {
78                const $element = $('#tick_count_' + event.id);
79                $element.css('opacity', '0.7');
80                $element.text('Билетов: ' + event.free + '/' + event.total);
81                setTimeout(() => $element.css('opacity', '1'), 500); // Уменьшил до 500мс
82            });
83        }
84    }
85    
86    // Только ПОСЛЕ объявления всех функций - выполняем код
87    $('#last-update').text('Обновлено: ' + new Date().toLocaleTimeString());
88    
89    // Первый запуск
90    if (typeof jsRadarioData !== 'undefined') {
91        getRadarioStat(jsRadarioData)
92            .then(data => updatePlaces(data))
93            .catch(error => console.error(error));
94    }
95    
96    // Периодическое обновление
97    let updateInterval = setInterval(() => {
98		
99		 if (document.hidden) {
100        return; // Не обновлять, если вкладка не активна
101    }
102        if (typeof jsRadarioData === 'undefined') {
103            console.warn('jsRadarioData не определен');
104            return;
105        }        
106        $('#refresh-indicator').addClass('spinning');
107        
108        getRadarioStat(jsRadarioData)
109            .then(data => {
110                updatePlaces(data);
111                $('#last-update').text('Обновлено: ' + new Date().toLocaleTimeString());
112            })
113            .catch(error => console.error('Ошибка обновления:', error))
114            .finally(() => {
115                $('#refresh-indicator').removeClass('spinning');
116            });
117    }, 300000); //5 мин
118    
119    $(window).on('beforeunload', function() {
120        clearInterval(updateInterval);
121    });
122 */   
123
124    // function fetchTickets() {
125        // $.ajax({
126            // url: 'https://radario.ru/json/widgets/afisha/events?key=0748464becdfa97cc7db28ac58872f232a164b0dc85a8db&page=0&pageSize=100&allowEventGrouping=false',
127            // type: 'GET',
128            // dataType: 'json',
129            // success: function(data) {
130                // if (data.events && Array.isArray(data.events)) {
131                    // $.each(data.events, function(index, event) {
132                        // $('#tick_count_' + event.id).text('Билетов: ' + event.ticketCount);
133                    // });
134                // }
135            // },
136            // error: function(xhr, status, error) {
137                // console.error('Ошибка при загрузке данных: ' + error);
138            // }
139        // });
140    // }
141    
142    // fetchTickets();
143    
144    // setInterval(fetchTickets, 20000);
145	
146	/* if ($.isArray(jsRadarioData) && jsRadarioData.length > 0) {			
147			jsRadarioData.forEach(function(item, index) {
148				// ПРОВЕРЯЕМ существование элемента перед вызовом виджета
149                    var buttonContainer = document.getElementById('btn_' + item);
150                    
151                    if (buttonContainer) {
152                        // Создаем кнопку покупки билетов через виджет Radario
153                        radario.Widgets.Event({
154                            "params": {
155                                "accentColor": "#D80606",
156                                "textColor": "#090000", 
157                                "backgroundColor": "#F2DCC2"
158                            },
159                            "buttonText": "Купить билет",
160                            "appendId": "btn_" + item,
161                            "buttonFontSize": "13px",
162                            "buttonPadding": "0.8rem 1.6rem",
163                            "buttonBorderRadius": "4px",
164                            "standalone": false,
165                            "createButton": true,
166                            "eventId": item
167                        });
168                    } else {
169                        console.warn('Элемент btn_' + item + ' не найден на странице');
170                    }
171			});
172		} else {
173			console.log('Не массив или пустой массив');
174		} */
175	
176});
177
178function setEmptyResult(){
179    let countDiv = $('.tab-content .active .afisha .afisha-item').length;
180    let countHideElement = $('.active .afisha .afisha-item[data-display="N"]').length;
181    console.log(countDiv);
182    console.log(countHideElement);
183    if (countDiv == countHideElement) {
184        if (!$('.tab-content .active .afisha .no-result').length) {
185            $('.tab-content .active .afisha').append('<p class="no-result">Спектаклей нет</p>');
186        }
187    }else{
188        $('.tab-content .active .afisha .no-result').remove();
189    }
190}
191$(document).on("click", "[data-monthbtn]", function () {
192
193    var month = $(this).attr('data-monthbtn');
194    console.log(month);
195
196    BX.localStorage.set('afishaMonth', month, 9999999);
197
198    $(this).closest('.afishaBtnsMonth').find('[active]').removeAttr('active');
199    $(this).attr('active', true);
200
201    $(document).find('[data-month]').attr('data-display', 'N');
202    $(document).find('[data-month="' + month + '"]').attr('data-display', '');
203    setEmptyResult();
204
205});
206
207(function() {
208    function initRadario() {
209        if (!window.radario) {
210            setTimeout(initRadario, 100);
211            return;
212        }
213        
214        if (typeof jsRadarioData !== 'undefined') {
215            if ($.isArray(jsRadarioData) && jsRadarioData.length > 0) {
216                jsRadarioData.forEach(function(item) {
217                    var btn = document.getElementById('btn_' + item);
218                    if (btn) {
219                        radario.Widgets.Event({
220                            params: {
221                                accentColor: "#D80606",
222                                textColor: "#090000",
223                                backgroundColor: "#F2DCC2"
224                            },
225                            buttonText: "Купить билет",
226                            appendId: "btn_" + item,
227                            buttonFontSize: "13px",
228                            buttonPadding: "0.8rem 1.6rem",
229                            buttonBorderRadius: "4px",
230                            standalone: false,
231                            createButton: true,
232                            eventId: item
233                        });
234                    }
235                });
236            }
237        } else {
238            // Данных нет - пробуем позже
239            setTimeout(initRadario, 200);
240        }
241    }
242    
243    // Загружаем скрипт Radario
244    if (typeof radario === 'undefined') {
245        var script = document.createElement('script');
246        script.src = 'https://radario.ru/scripts/widget.js';
247        script.async = true;
248        script.onload = initRadario;
249        document.head.appendChild(script);
250    } else {
251        initRadario();
252    }
253})();

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.