PageSourceSearch

https://bntnews.bg/box2/js/survey.js

js bntnews.bg collected 2026-10-02 02:29:39 UTC 3,030 bytes, 86 lines download raw bytes

1// ES5 compatible code with jQuery - Survey namespace
2var SrvyPoll = {
3    submitVote: function(surveyId) {
4        var selectedOption = $('input[name="srvy-vote' + surveyId + '"]:checked').val();
5        var errorMsg = $('#srvy-errorMessage');
6        var successMsg = $('#srvy-successMessage');
7        var voteBtn = $('#srvy-voteButton');
8
9        // Hide previous messages
10        errorMsg.hide();
11        successMsg.hide();
12
13        // Validation
14        if (!selectedOption) {
15            errorMsg.text('Моля направете вашия избор първо').show();
16            return;
17        }
18
19        // Show loading state
20        voteBtn.addClass('srvy-loading').prop('disabled', true).text('');
21
22        // AJAX request
23        $.ajax({
24            url: '/survey/vote',
25            type: 'POST',
26            data: {
27                survey: surveyId,
28                vote: selectedOption
29            },
30            dataType: 'json',
31            success: function(response) {
32                voteBtn.removeClass('srvy-loading').prop('disabled', false).text('Гласувай');
33
34                if (response.success) {
35                    successMsg.text(response.msg).show();
36
37                    // Hide voting form and show results
38                    setTimeout(function() {
39                        $('#srvy-votingForm').fadeOut(200, function() {
40                            $('#srvy-resultsContainer').html(response.html).addClass('srvy-fade-in').show();
41                            SrvyPoll.animateResults();
42                        });
43                    }, 600);
44                } else if (response.error) {
45                    errorMsg.text(response.msg).show();
46                }
47            },
48            error: function() {
49                voteBtn.removeClass('srvy-loading').prop('disabled', false).text('Гласувай');
50                errorMsg.text('Възникна грешка. Моля, опитайте отново.').show();
51            }
52        });
53    },
54
55    animateResults: function() {
56        // Animate progress bars
57        setTimeout(function() {
58            $('.srvy-progress-fill').each(function() {
59                var percentage = $(this).data('percentage') || 0;
60                $(this).css('width', percentage + '%');
61            });
62        }, 200);
63    }
64};
65
66// Global function for button onclick
67function srvySubmitVote(surveyId) {
68    SrvyPoll.submitVote(surveyId);
69}
70
71// Document ready
72$(document).ready(function() {
73    // Auto-hide error messages when user selects an option
74    $('input[name^="srvy-vote"]').on('change', function() {
75        $('#srvy-errorMessage').hide();
76    });
77
78    // Add hover effects for vote options
79    $('.srvy-vote-option').on('mouseenter', function() {
80        $(this).find('.srvy-custom-radio').css('border-color', '#B9326F');
81    }).on('mouseleave', function() {
82        if (!$(this).find('input[type="radio"]').is(':checked')) {
83            $(this).find('.srvy-custom-radio').css('border-color', '#ddd');
84        }
85    });
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.