PageSourceSearch

https://www.bilete-fcsb.ro/public/js/ajax2.js?v=21

js bilete-fcsb.ro collected 2026-09-28 09:18:20 UTC 19,073 bytes, 490 lines download raw bytes

1function etichetaRand(numarRand) {
2    // randul 0 (pista) se afiseaza ca PISTA, nu ca "R 0"
3    return parseInt(numarRand) === 0 ? 'PISTA' : 'R ' + numarRand;
4}
5
6var bilete_deja_alese = [];
7var selectate = 0;
8var continua_cumparaturile_link = BASE_URL;
9var finalizeaza_comanda_link = BASE_URL + 'cos_produse';
10
11function showGlobalLoader() {
12    $('#global-loader-overlay').css('display', 'flex');
13}
14
15function hideGlobalLoader() {
16    $('#global-loader-overlay').hide();
17}
18
19const LOADER_DELAY_MS   = 500;   // 0.5s până apare loaderul global
20const WATCHDOG_MS       = 10000; // 10s fallback hard-unlock
21
22let aranjareBusy = 0;
23let aranjareLoaderTimer = null;
24let aranjareWatchdog = null;
25let aranjareOverlayEl = document.getElementById('aranjare_overlay');
26let resizeObserver = null;
27
28function targetEl() {
29    return document.getElementById('locuri_content') || document.getElementById('aranjare_locuri');
30}
31
32function positionOverlay() {
33    if (!aranjareOverlayEl) aranjareOverlayEl = document.getElementById('aranjare_overlay');
34    const tgt = targetEl(); if (!aranjareOverlayEl || !tgt) return;
35    const r = tgt.getBoundingClientRect();
36    Object.assign(aranjareOverlayEl.style, {
37        left: r.left + 'px', top: r.top + 'px',
38        width: r.width + 'px', height: r.height + 'px'
39    });
40}
41
42function bindTracking() {
43    window.addEventListener('scroll', positionOverlay, { passive: true });
44    window.addEventListener('resize', positionOverlay);
45    window.addEventListener('orientationchange', positionOverlay);
46    const tgt = targetEl();
47    if ('ResizeObserver' in window && tgt) {
48        resizeObserver = new ResizeObserver(positionOverlay);
49        resizeObserver.observe(tgt);
50    }
51}
52
53function unbindTracking() {
54    window.removeEventListener('scroll', positionOverlay);
55    window.removeEventListener('resize', positionOverlay);
56    window.removeEventListener('orientationchange', positionOverlay);
57    if (resizeObserver) { resizeObserver.disconnect(); resizeObserver = null; }
58}
59
60function forceUnlockAranjare() {
61    aranjareBusy = 0;
62    clearTimeout(aranjareLoaderTimer);
63    clearTimeout(aranjareWatchdog);
64    hideGlobalLoader();
65    if (aranjareOverlayEl) {
66        aranjareOverlayEl.classList.remove('active');
67        Object.assign(aranjareOverlayEl.style, { width: '0px', height: '0px' });
68    }
69    unbindTracking();
70}
71
72function startAranjareWait() {
73    if (++aranjareBusy === 1) {
74        positionOverlay();
75        bindTracking();
76        aranjareOverlayEl.classList.add('active');
77        // loader global doar după 0.5s
78        aranjareLoaderTimer = setTimeout(showGlobalLoader, LOADER_DELAY_MS);
79        // watchdog: deblochează în caz de “dead end”
80        aranjareWatchdog = setTimeout(() => {
81            console.warn('[watchdog] force unlock overlay after', WATCHDOG_MS, 'ms');
82            forceUnlockAranjare();
83        }, WATCHDOG_MS);
84    }
85}
86
87function stopAranjareWait() {
88    if (--aranjareBusy <= 0) {
89        aranjareBusy = 0;
90        clearTimeout(aranjareLoaderTimer);
91        clearTimeout(aranjareWatchdog);
92        hideGlobalLoader();
93        if (aranjareOverlayEl) {
94            aranjareOverlayEl.classList.remove('active');
95            Object.assign(aranjareOverlayEl.style, { width: '0px', height: '0px' });
96        }
97        unbindTracking();
98    }
99}
100
101
102function afiseazaSector (idSector, numar, numeSector){
103
104
105  $.post(BASE_URL+'main/getBileteSector/'+idSector,
106    function(data){
107
108        $('#aranjare_locuri div').empty();
109        if(/sector/i.test(numar)) {
110            // numar poate fi numele complet ("TRIBUNA 2 CENTRAL SECTOR K"),
111            // deci pastram doar ce urmeaza dupa "SECTOR" (case-insensitive)
112            $('#sector-ales').html(numar.replace(/^.*?sector\s+/i, ''));
113        } else {
114            $('#sector-ales').html(numar);
115        }
116
117        $('#aranjare_locuri p.categorie-sector, #aranjare_locuri p.stadion-randul-1').show();
118
119        if (data['success'] === 0 && data['code'] === 10 && data['errors'] && data['errors'].length) {
120            $('#sector-ales').html('<br />' + data['errors'][0]['message']);
121            return;
122        }
123
124        if(data['bilete_deja_alese']){
125            bilete_deja_alese = new Array();
126            var j = 0;
127            for (i in data['bilete_deja_alese']){
128                bilete_deja_alese[j] = data['bilete_deja_alese'][i].bilet_id;
129                j++;
130            }
131
132        }
133
134
135        if (data['bilete_sector'] && data['bilete_sector'][0]){
136            $('#sector-ales').html();
137
138            var rand_curent = data['bilete_sector'][0].numar_rand;
139            var content = '<p>';
140            var break_after = data['bilete_sector'][0].break_after;
141
142			content += '<div class="rand"><span>'+etichetaRand(rand_curent)+'</span>';
143
144            for(var i=0;i<data['bilete_sector'].length;i++){
145
146
147                if (parseInt(data['bilete_sector'][i].numar_rand)<parseInt(rand_curent)){
148                    content += '<div><p></p></div>';
149                    break_after = data['bilete_sector'][i].break_after;
150                    // randurile se afiseaza descrescator (R10 -> R1), deci randul gol
151                    // (scari / culoar) apare la intrarea in randul marcat cu rand_break_after
152                    if (parseInt(data['bilete_sector'][i].rand_break_after) > 0) {
153                        content += '</div><div class="rand rand-gol"><span>&nbsp;</span><em>SCARI / CULOAR</em>';
154                    }
155                    content += '</div><div class="rand"><span>'+etichetaRand(data['bilete_sector'][i].numar_rand)+'</span>';
156                }
157
158                if (data['bilete_sector'][i].empty_places_before) {
159                    let emptyPlacesBefore = parseInt(data['bilete_sector'][i].empty_places_before);
160                    for (let i = 0; i < emptyPlacesBefore; i++) {
161                        content += '<a class="empty_place loc-empty"></a>';
162                    }
163                }
164
165                rand_curent = data['bilete_sector'][i].numar_rand;
166
167                clasa_ba = '';
168                // break_after e numar de loc (gol pe orizontala). Cand randul e marcat ca
169                // avand rand gol dupa el, valoarea nu se refera la un loc, deci o ignoram.
170                if (break_after > 0 && !parseInt(data['bilete_sector'][i].rand_break_after)
171                    && parseInt(data['bilete_sector'][i].numar_loc) === break_after ) {
172                    clasa_ba = 'break_after';
173                }
174
175                if (parseInt(data['bilete_sector'][i].status) === 0) {
176                    content += '<a class="loc-lib ' + clasa_ba + '" onclick="adaugaBilet(' + data['bilete_sector'][i].id + ', ' + data['bilete_sector'][i].id_loc + ')" title="' + randul + ' ' + data['bilete_sector'][i].numar_rand + ' ' + locul + ' ' + data['bilete_sector'][i].numar_loc + '" data-locul="' + data['bilete_sector'][i].numar_loc + '" id="b' + data['bilete_sector'][i].id + '"></a>';
177                } else if ($.inArray(data['bilete_sector'][i].id,bilete_deja_alese)>=0) {
178                    content += '<a class="loc-sel ' + clasa_ba + '" onclick="stergeBilet(' + data['bilete_sector'][i].id + ',' + data['bilete_sector'][i].id_loc + ')" title="' + randul + ' ' + data['bilete_sector'][i].numar_rand + ' ' + locul + ' ' + data['bilete_sector'][i].numar_loc + '"  data-locul="' + data['bilete_sector'][i].numar_loc + '" id="b' + data['bilete_sector'][i].id + '"></a>';
179                } else {
180                    content += '<a class="loc-ocu ' + clasa_ba + '" onclick="biletOcupat()" title="' + randul + ' ' + data['bilete_sector'][i].numar_rand + ' ' + locul + ' ' + data['bilete_sector'][i].numar_loc + '" data-locul="' + data['bilete_sector'][i].numar_loc + '" id="b' + data['bilete_sector'][i].id + '"></a>';
181                }
182
183                if (data['bilete_sector'][i].empty_places_after) {
184                    let emptyPlacesAfter = parseInt(data['bilete_sector'][i].empty_places_after);
185                    for (let i = 0; i < emptyPlacesAfter; i++) {
186                        content += '<a class="empty_place loc-empty"></a>';
187                    }
188                }
189            }
190			content += '</div>';
191            content += '</p>';
192            $('#aranjare_locuri div').append(content);
193
194            // $('#aranjare_locuri').scroll(function() {
195            //     let _this = this
196            //     $(".gradient-bar", this).css({
197            //         display: _this.scrollWidth === (_this.scrollLeft + _this.clientWidth) ? 'none' : 'block'
198            //     });
199            // }).scroll();
200
201            let wrapper1 = document.getElementById('double_scroll');
202            let wrapper2 = document.getElementById('aranjare_locuri');
203            wrapper1.onscroll = function() {
204                wrapper2.scrollLeft = wrapper1.scrollLeft;
205            };
206            wrapper2.onscroll = function() {
207                wrapper1.scrollLeft = wrapper2.scrollLeft;
208            };
209
210            $('#aranjare_locuri').scroll(function() {
211                if($('#aranjare_locuri').scrollLeft() > 0){
212                    $('.gradient-bar').css("display", "none");
213                }
214            });
215
216            (function($) {
217                $.fn.scrollWidthPx = function() {
218                    return this.get(0).scrollWidth;
219                }
220            })(jQuery);
221
222            let widthLocuriScroll = $('#aranjare_locuri').scrollWidthPx();
223            let widthLocuriSection = $('.legenda-locuri').scrollWidthPx();
224
225            $('#double_scroll').css('width', widthLocuriSection + 'px');
226            $('#double_scroll > div').css('width', widthLocuriScroll + 'px');
227
228            if(widthLocuriScroll > widthLocuriSection){
229                $('#double_scroll').css("display", "block");
230                $('#aranjare_locuri .categorie-sector').css("margin-bottom", "25px");
231                $('.icon-scroll-horizontal').css("display", "block");
232            } else {
233                $('#double_scroll').css("display", "none");
234                $('#aranjare_locuri .categorie-sector').css("margin-bottom", "15px");
235                $('.icon-scroll-horizontal').css("display", "none");
236                $('.gradient-bar').css("display", "none");
237            }
238        } else if (data['message']) {
239            $('#sector-ales').html('<br />' + data['message']);
240        } else{
241            $('#sector-ales').html('<br />'+parametri_invalizi_reia);
242        }
243
244    }, 'json');
245
246
247}
248
249
250function renderSelectedTickets(tickets) {
251    const $ul   = $('#selected_tickets_list');
252    if (!$ul.length) return;
253
254    const $card = $('#selected_tickets_card').length ? $('#selected_tickets_card') : $ul.closest('.card');
255
256    if (Array.isArray(tickets) && tickets.length > 0) {
257        $ul.empty();
258
259        tickets.forEach((t) => {
260            const name    = t.nume || '';
261            const biletId = t.bilet_id;
262            const locId   = t.loc_id;
263
264            const $li = $('<li class="list-group-item d-flex justify-content-between align-items-start">')
265                .css({ padding: '10px 12px', gap: '8px' });
266
267
268            const $name = $('<span>')
269                .text(name)
270                .css({
271                    flex: '1 1 auto',
272                    whiteSpace: 'normal',
273                    wordBreak: 'break-word',
274                    overflowWrap: 'anywhere'
275                });
276
277
278            const $btn = $('<button type="button" class="btn btn-sm btn-outline-danger">' + del + '</button>')
279                .css({
280                    flex: '0 0 auto',
281                    flexShrink: 0,
282                    whiteSpace: 'nowrap',
283                    wordBreak: 'keep-all',
284                    overflowWrap: 'normal',
285                    hyphens: 'none',
286                    WebkitHyphens: 'none',
287                    padding: '2px 8px',
288                    cursor: 'pointer'
289                })
290                .on('click', function (e) {
291                    e.preventDefault(); e.stopPropagation();
292                    if (typeof stergeBilet === 'function') stergeBilet(biletId, locId);
293                });
294
295            $li.append($name, $btn).appendTo($ul);
296
297        });
298
299        $card.show();
300    } else {
301        $ul.empty();
302        $card.hide();
303    }
304}
305
306
307function adaugaBilet(idBilet, loc) {
308    if (aranjareBusy > 0) return; // opțional: ignoră tap-uri multiple
309    startAranjareWait();
310
311    // helper local: centrează vertical mesajul și evită ruperea pe rând nou a <strong>
312    const setInfoActiuniHtml = (html) => {
313        const $box = $('.info-actiuni');
314        if ($box.children('.msg').length === 0) {
315            $box.wrapInner('<span class="msg"></span>');
316        }
317        $box.children('.msg').html(html);
318        $box.show();
319    };
320
321    const url = $('#aceleasi_locuri').is(':checked')
322        ? BASE_URL + 'cos_produse/ajaxAddLoc/' + loc
323        : BASE_URL + 'cos_produse/ajaxAddBilet/' + idBilet;
324
325    $.ajax({ url, method: 'POST', dataType: 'json' })
326        .done(function (data) {
327            var plus = '';
328
329            if (data['success'] === 0 && data['code'] === 10 && data['errors'] && data['errors'].length) {
330                setInfoActiuniHtml(data['errors'][0]['message'] + ' ' + plus);
331                return;
332            }
333
334            if (data['code'] == 0) { // ok
335
336                renderSelectedTickets(data['tickets'] || []);
337
338                $('#b' + idBilet).removeClass('loc-lib').addClass('loc-sel');
339                $('#b' + idBilet)[0].onclick = function () { stergeBilet(idBilet, loc); return false };
340
341                if ($('#nr_bilete_alese_meci').length)
342                    selectate = $('#nr_bilete_alese_meci').val();
343                selectate++;
344                if ($('#nr_bilete_alese_meci').length) $('#nr_bilete_alese_meci').val(selectate);
345
346                var target = $('#nr_bilete_dorite').val();
347
348                if (selectate == target)
349                    $('.div-info').hide();
350                else {
351                    var dif = target - selectate;
352                    if (dif == 1) {
353                        if (data['is_package']) {
354                            $('.div-info span').html('1 ' + pachet);
355                            plus = '<br />' + mai_ai + '<strong> 1 ' + pachet + '</strong> ' + de_ales + '.';
356                        } else {
357                            $('.div-info span').html('1 ' + bilet);
358                            plus = '<br />' + mai_ai + '<strong> 1 ' + bilet + '</strong> ' + de_ales + '.';
359                        }
360                    }
361                    else {
362                        if (data['is_package']) {
363                            $('.div-info span').html(dif + ' ' + pachete);
364                            plus = '<br />' + mai_ai + '<strong> ' + dif + ' ' + pachete + '</strong> ' + de_ales + '.';
365                        } else {
366                            $('.div-info span').html(dif + ' ' + bilete);
367                            plus = '<br />' + mai_ai + '<strong> ' + dif + ' ' + bilete + '</strong> ' + de_ales + '.';
368                        }
369                    }
370                    if ($('.tab-meci').length) {
371                        $('.div-info').hide();
372                    } else {
373                        $('.div-info').show();
374                    }
375                }
376
377                if (data['is_package']) {
378                    setInfoActiuniHtml(
379                        pachetul_pentru + ' <strong>' + $('#b' + idBilet).attr("title") + '</strong>' + pachetul_a_fost_rezervat + ' ' + plus
380                    );
381                } else {
382                    setInfoActiuniHtml(
383                        biletul_pentru + ' <strong>' + $('#b' + idBilet).attr("title") + '</strong>' + a_fost_rezervat + ' ' + plus
384                    );
385                }
386
387            } else {
388                setInfoActiuniHtml(data['message'] + ' ' + plus);
389            }
390        })
391        .fail(function (_x, _s, err) {
392            setInfoActiuniHtml('Error');
393        })
394        .always(function () {
395            stopAranjareWait();
396        });
397}
398
399
400function stergeBilet (idBilet, loc){
401
402    if ($('#aceleasi_locuri').is(':checked'))
403        url = BASE_URL+'cos_produse/ajaxRemoveLoc/'+loc;
404    else
405        url = BASE_URL+'cos_produse/ajaxRemoveBilet/'+idBilet;
406
407    $.ajax({ url, method:'POST', dataType:'json' })
408        .done(function(data){
409            var plus = '';
410
411            if (data['code'] == 0){ //ok
412
413                renderSelectedTickets(data['tickets'] || []);
414
415                $('#b'+idBilet).removeClass('loc-sel').addClass('loc-lib');
416                $('#b'+idBilet)[0].onclick = function(){ adaugaBilet(idBilet, loc); return false };
417
418                if ($('#nr_bilete_alese_meci').length)
419                    selectate = $('#nr_bilete_alese_meci').val();
420                selectate --;
421                if ($('#nr_bilete_alese_meci').length) $('#nr_bilete_alese_meci').val(selectate);
422
423                var target = $('#nr_bilete_dorite').val();
424
425                if (selectate==target)
426                    $('.div-info').hide();
427                else{
428                    var dif = target-selectate;
429                    if (dif==1){
430                        if (data['is_package']) {
431                            $('.div-info span').html('1 '+pachet);
432                            plus = '<br />'+mai_ai+' 1 '+pachet+' '+de_ales+'.';
433                        } else {
434                            $('.div-info span').html('1 '+bilet);
435                            plus = '<br />'+mai_ai+' 1 '+bilet+' '+de_ales+'.';
436                        }
437
438                    }
439                    else {
440                        if (data['is_package']) {
441                            $('.div-info span').html(dif + ' ' + pachete);
442                            plus = '<br />' + mai_ai + ' ' + dif + ' ' + pachete + ' ' + de_ales + '.';
443                        } else {
444                            $('.div-info span').html(dif + ' ' + bilete);
445                            plus = '<br />' + mai_ai + ' ' + dif + ' ' + bilete + ' ' + de_ales + '.';
446                        }
447                    }
448
449                    if ($('.tab-meci').length){
450                        $('.div-info').hide();
451                    }
452                    else {
453                        $('.div-info').show();
454                    }
455                }
456            }
457            $('.info-actiuni').html(data['message']+' '+plus);
458        })
459        .fail(function(_x, _s, err){
460            $('.info-actiuni').html('A apărut o eroare: ' + err).show();
461        })
462        .always(function(){
463            stopAranjareWait();
464        });
465
466}
467
468function cumparaBilete (){
469
470
471    $.post(BASE_URL+'cos_produse/finishComandaActiva/',
472        function(data){
473            $('.mesaj').remove();
474
475            if (data['code']===0){
476                $('#finishOrderModal').modal('show');
477            }else if (data['code']===20){
478                $('#selectTicketsModal').modal('show');
479            }
480        }, 'json');
481
482
483
484}
484
485
486function biletOcupat (){
487    $('.info-actiuni').show();
488    $('.info-actiuni').html(loc_indispobinil);
489
490}

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.